To add a new activity to this project, you need to fork this repository, create a branch, create a pull request, and of course develop your new activity. The following sections go over the specific steps. A later section discusses how to modify an action later on using another pull request.
To be able to create pull request, you will need to set up a fork and a local repository on your computer (to make changes and to test code locally):
- Fork this repository on GitHub.
- In the web interface, there is a Fork button.
- Clone your fork on your computer.
- For example, in the command line, use the
git clone
commmand.
- For example, in the command line, use the
- Create a new Python script according to the template
- There is a template called
activity_template.py
in theactivities
directory which gives information about the specific conventions. - Use a unique filename, for example your name or your unique algorithm name.
- You can use the Simple Python Editor in GRASS GIS.
- There is a template called
- Develop a new analysis and write it as a function in the file.
- Test your analysis locally on your computer by executing the script.
- Use the NC SPM sample location for GRASS GIS.
- If you are using the Simple Python Editor, just run it from there.
- Create a new Python script according to the template
- There is a template called
config_template.json
in theactivities
directory which provides an example of a minimalistic activity configuration. - Again, use a unique filename.
- There is a template called
- Set
analyses
value to the filename of your Python script. - Change
title
of the task and modifylayers
to fit your needs.
Once you have your new files ready, you can do all the Git related steps (you could do them as your are working, too). We will use command line here, but you can use any Git desktop tool including GitHub Desktop.
Create a new branch for your chaneges and switch to it (here, we will call it add-awesome-activity
):
git checkout -b add-awesome-activity
Add Python script with your function and the JSON file to the repository as new files:
git add activities/awesome-activity.py
git add activities/awesome-activity.json
Record the changes:
git commit -am "Add awesome activity"
Publish the changes into your fork (origin
is how Git referes to the remote repository you cloned from):
git push origin add-awesome-activity
This will give your URL to create pull request on GitHub or simply go to GitHub and it will suggest you to open a PR.
Modifying your activity, once it was merged into the main repository, requires you to update your fork first. However, to do that, you need to add the main repository as another remote repository to the clone on your local machine.
So, first, we add the main repository as another remote repository called upstream
git remote add upstream https://github.com/ncsu-geoforall-lab/gis714-2020-tangible-landscape
Second, switch to the master branch of your repository (the master branch should have no changes in it since you used a separate branch to make the changes):
git checkout master
Third, update the master branch of your local repository to match the master branch from the main repository with these two commands:
git fetch upstream
git rebase upstream/master
Optionally, you can push the update to your remote repository, i.e., your fork on GitHub:
git push
Now when your local master branch is up to date with the master branch of the main repository, you can just follow the instructions for creating a new activity, i.e., you need to:
- create a new branch,
- make changes,
- make commits,
- publish (push) the changes online, and
- create a pull request.