This is a brief guide to contributing to CLMM, including information about identifiying code issues and submitting code changes or documentation.
- Identifying Issues
- Making and submitting changes
- Adding documentation
- Reviewing an open pull request
- Steps to merging a pull request
- Updating Public Documentation on lsstdesc.org
- Additional resources
- Contact
Action items for CLMM code improvements are listed as GitHub Issues.
Issues marked with the label good first issue
are well-suited for new contributors.
Once you've created a local copy of CLMM on your machine, you can begin making changes to the code and submitting them for review. To do this, follow the following steps from within your local copy of CLMM (forked or base).
- Checkout a new branch to contain your code changes independently from the
main
repository. Branches allow you to isolate temporary development work without permanently affecting code in the repository.Yourgit checkout -b branchname
branchname
should be descriptive of your code changes. If you are addressing a particular issue #xx
, thenbranchname
should be formatted asissue/xx/summary
wheresummary
is a description of your changes. - Make your changes in the files stored in your local directory.
- Commit and push your changes to the
branchname
branch of the remote repository.git add NAMES-OF-CHANGED-FILES git commit -m "Insert a descriptive commit message here" git pull origin main git push origin branchname
- You can continue to edit your code and push changes to the
branchname
remote branch. Once you are satisfied with your changes, you can submit a pull request to merge your changes frombranchname
into themain
branch. Navigate to the CLMM Pull Requests and click 'New pull request.' Selectbranchname
, fill out a title and description for the pull request, and, optionally, request review by a CLMM team member. Once the pull request is approved, it will be merged into the CLMMmain
branch.
NOTE: Code is not complete without unit tests and documentation. Please ensure that unit tests (both new and old) all pass and that docs compile successfully.
To test this, first install the code by running python setup.py install --user
(required after any change whatsoever to the .py
files in clmm/
directory). To run all of the unit tests, run pytest
in the root package directory. To test the docs, in the root package directory after installing, run ./update_docs
. This script both deletes the old compiled documentation files and rebuilds them. You can view the compiled docs by running open docs/_build/html/index.html
.
NOTE2: If the changes you are making affect which CCL versions are compatible with the code,
please update clmm/theory/_ccl_supported_versions.py
, README.md
and INSTALL.md
accordingly.
If you are adding documentation either in the form of example jupyter notebooks or new python modules, your documentation will need to compile for our online documentation hosted by the LSST-DESC website: http://lsstdesc.org/CLMM/
We have done most of the hard work for you. Simply edit the configuration file, docs/doc-config.ini
. If you are looking at add a module, put the module name under the APIDOC
heading. If you are adding a demo notebook to demonstrate how to use the code, place the path from the docs/
directory to the notebook under the DEMO
heading. If you are adding an example notebook that shows off how to use CLMM
to do science, place the path from the docs/
directory to the notebook under the EXAMPLE
heading.
Once it has been added to the config file, simply run ./update_docs
from the top level directory of the repository and your documentation should compile and be linked in the correct places!
To review an open pull request submitted by another developer, there are several steps that you should take.
- Code changes: For each new or changed file, ensure that the changes are correct, well-documented, and easy to follow. If you notice anything that can be improved, leave an inline comment (click the line of code in the review interface on Github).
- Documentation: Double check any relevant documentation. For any new or changed code, ensure that the documentation is accurate (i.e. references, equations, parameter descriptions).
- Code formatting: Make sure the code formatting is up to standards, you can do this by running a linter on any new or changed files
pylint {filename}
. This will take a look at the file and identify any style problems. If there are only a couple, feel free to resolve them yourself, otherwise leave a comment in your review that the author should perform this step. Tips for formatting: CLMM is setup to be formatted automatically with theblack
package (can be installed viapip install black
). Just runblack {filename}
for specific file orblack .
inside the main CLMM directory for the whole repo. Bonus tip: This can also be done for notebooks, just install the notebook extention:pip install "black[jupyter]"
. - Check unittests: For any new or changed code, ensure that there are new tests in the appropriate directory. Try to come up with additional tests that either do or can break the code. If you can think of any such tests, suggest adding them in your review.
Now, make sure everything is ok with unit tests, notebooks and documentation. These steps (except running the notebooks) are run automatically on each pull request on github (check details
on Build and Check / build-gcc-ubuntu (pull_request)
section at the end of the PR and coverage
under the coveralls
comment in the middle of the PR), but you can also run them manually on your local machine:
- Run unittests: Next, checkout the branch to a location that you can run
CLMM
. From the top level package directory (the directory that hassetup.py
) install the code viapython setup.py install --user
. Then, runpytest
to run the full testing suite. - Check coverage: Check the coverage of the code, i. e. how many lines of the code are being tested in our unittests. To do it locally, you need the
pytest-cov
library (it can be insatalled withpip
). Then run the commandpytest tests/ --cov=clmm --cov-report term-missing
, it will tell you what fraction of the code is being tested and which lines are not being tested. - Notebooks: Make sure all notebooks can run correctly. We provide a convenient bash script to compile the documentation, run
./run_notebooks
in the mainCLMM
directory. It will create an executed version of all notebooks in the_executed_nbs/
directory. By default it uses apython3
kernel, if you want to choose another one, just pass it to the command:./run_notebooks -k MY_KERNEL
. (Note that depending on your theory backend, some cells in some notebooks will give an error. This expected behaviour is explicitely mentioned before the cells and should not be a cause of worry.) - Documentation: We can now check that the documentation looks as it should. We provide a convenient bash script to compile the documentation. To completely rebuild the documentation, AFTER INSTALLING (if you made any changes, even to docstrings), run
./update_docs
. This will delete any compiled documentation that may already exist and rebuild it. If this runs without error, you can then take a look byopen docs/_build/html/index.html
. Make sure any docstrings that were changed compile correctly. - Install: Finally, install (
python setup.py install --user
), run tests (pytest
) and notebooks (./run_notebooks
), and compile documentation (./update_docs
). If everything passes, accept the review!
(Developer tip: you can install CLMM
in a editable mode, where the latest files on the repo will always be used, with the command pip install . -e
)
NOTE: We have had several branches that have exploded in commit number. If you are merging a branch and it has more than ~20 commits, strongly recommend using the "Squash and Merge" option for merging a branch.
To ensure consistency between our code and documentation, we need to take care of a couple of more things after accepting a review on a PR into main
.
- In the branch of the pull request, change the version number of the code located in
clmm/__init__.py
, commit and push. If you are unsure of how you should change the version number, don't hesitate to ask!
We use semantic versioning, X.Y.Z. If the PR makes a small change, such as a bug fix, documentation updates, style changes, etc., increment Z. If the PR adds a new feature, such as adding support for a new profile, increment Y (and reset Z to 0). If a PR adds a feature or makes a change that breaks the old API, increment X (and reset Y and Z to 0). After the first tagged release of CLMM, anything that is a candidate to increment X should be extensively discussed beforehand.
- "Squash and Merge" the pull request into
main
. It asks for a squashed commit message. This should be descriptive of the feature or bug resolved in the PR and should be pre-prended by a conventional commit scope.
Please choose from fix:
, feat:
, build:
, chore:
, ci:
, docs:
, style:
, refactor:
, perf:
, test:
. If this commit breaks the previous API, add an explanation mark (for example, fix!:
). Definitions of each scope can be found at the above link.
Note: fix:
should correspond to version changes to Y. The rest of the scopes above should be version changes to Z.
-
Tag and push this new version of the code. In the
main
branch use the following commands:git tag X.Y.Z git push --tag
of course replacing X.Y.Z
by the new version.
This is easy! Once you have merged all approved changes into main
, you will want to update the public documentation.
All these steps should be done on the publish-docs
branch (just git checkout publish-docs
on your local computer):
- Merge all of the latest changes from main
git merge main
. - If you have figures in notebooks that you would like rendered on the website, you will want to execute all cells of demo notebooks.
- From the
main
CLMM directory (the one that containssetup.py
) run./publish_docs
(note, this is different from./update_docs
that you did in your development branch) and it does all of the work for you (including automatically pushing changes to Github)!
Here's a list of additional resources which you may find helpful in navigating git for the first time.
- The DESC Confluence page on Getting Started with Git and Github
- Phil Marshall's Getting Started repository and FAQ
- Phil Marshall's Git tutorial video lesson
- The Github Help Pages
- Michel Aguena (APC / LIneA)
- Doug Applegate (Novartis)
- Camille Avestruz (University of Michigan)
- Lucie Baumont (SBU)
- Miyoung Choi (UTD)
- Celine Combet (LPSC)
- Matthew Fong (UTD)
- Shenming Fu(Brown)
- Matthew Ho (CMU)
- Matthew Kirby (Arizona)
- Brandyn Lee (UTD)
- Anja von der Linden (SBU)
- Binyang Liu (Brown)
- Alex Malz (CMU)
- Tom McClintock (BNL)
- Hironao Miyatake (Nagoya)
- Constantin Payerne (LPSC)
- Mariana Penna-Lima (UnB - Brasilia / LIneA)
- Marina Ricci (LMU)
- Cristobal Sifon (Princeton)
- Melanie Simet (JPL)
- Martin Sommer (Bonn)
- Sandro Vitenti (LIneA / UEL - Londrina)
- Heidi Wu (Ohio)
- Mijin Yoon (RUB)
The current administrators of the repository are Michel Aguena, Camille Avestruz, Céline Combet, Matthew Kirby, and Alex Malz.