Become a contributor¶
As a scientist, contributing to open source software projects can increase the impact of the code you write. The tools you help develop can be used by many other researchers, since the tools are freely available for anyone to use. Often different people will develop tools to do the same type of analysis separately. This leads to duplicate work, which can be greatly reduced by contributing these tools to an open source project.
Open source software has many advantages:
It is better. Since the source code is open, anyone can help finding errors, improving the code and adding functionality. More about that here.
You can make the tools you want and need, not needing to wait for a company to care.
It is for free.
By contributing to open source projects you will gain more experience with programming and how to do software development as a part of a community.
You can check out who is contributing to Atomap here.
What to contribute¶
Firstly, as an Atomap user you may find that you miss some functionality. Obviously, you can develop the tools you are missing, and improve existing tools. Contributing documentation, and doing language checks is also highly appreciated. You can read more about contributing to open source projects here.
For software development projects, version control systems are a vital part of the workflow. Atomap uses Git as version control system. One version of Atomap is the most recently released version, another is the development version. When new functionality is created or old functionality improved, new branches of the development version is typically made. The branch is merged back into the master development version when it is done.
You only need to know a few basic things about git to be able to start developing. Git is the most commonly used version control system, so there is a lot of user guides out there. You may consult the nice GitLab userguide. Below, you’ll also find and outline of the basic first steps. Often as with tools, the best way to learn is by using.
First steps: setting up git¶
Make your own fork of Atomap here. Click on the fork button. You need to be logged in.
Make ssh-keys for your account on GitLab, see this guide.
Clone the fork to your computer, as shown here. (Use something like
git clone email@example.com:username/atomap.git, with your own username). This will create a new folder called Atomap, and all the Atomap source code will be inside this folder.
You can now install the development version if Atomap by using the terminal. Enter the atomap folder in a terminal, and write
pip3 install -e .(if that doesn’t work, try
pip install -e .).
git remote -vto check the address for your remote origin (your fork on GitLab). You can add a link to the upstream version of Atomap by writing
git remote add upstream firstname.lastname@example.org:atomap/atomap.git. Type
git remote -vagain to check if you have registered the address for both remote origin and remote upstream.
Second steps: Adding something¶
With git set up and the development version of Atomap installed, you can start adding code. In this example, spelling errors in the docstring of one function will be fixed. This is fairly simple and manageable for a first contribution.
In the terminal, make a branch for your first development. For example a branch for fixing spelling errors, called FixTypos:
git checkout -b FixTypos. The -b is for creating a new branch. Too see what branches you have, write
git branch. Make sure you are in the correct branch. After having the created it, you can switch to this branch through
git checkout FixTypos.
Fix typos in a file, save.
Check what has been changed. In the terminal, in the Atomap folder:
git status. The file you have edited should be listed in red. If you want to see what is changed in the files, write
git status -vv. This shows what is different in the current version compared to the last commit.
Add your file to the stage for commit by
git add filename
Commit your file by
git commit. Write a short but clear commit message. Such as “Fixed typos in docstring in sublattice”.
Push your commit
git push origin FixTypos. This synchronizes the changes you have done to your forked remote version on GitLab.
When you are ready to add the branch to the Atomap development version, make a request for merging the commit into Atomap. See here.
You move from branch to branch with the
git checkout branch_name command.
When starting some new branch, remember to update your master fork by pulling from Atomap (upstream master).
Return to your master branch
git checkout master
Pull the newest changes from Atomap
git pull upstream master.
Consult the nice GitLab userguide. Google stuff. Or ask for help here, by adding an issue.
HyperSpy’s contribution guide: a lot of nice information on how to contribute to a scientific Python project.
Atomap follows the Style Guide for Python Code. These are just some rules for consistency that you can read all about in the Python Style Guide.
The Python programming language, for beginners.