Contribution Guide#
Contributions are highly welcomed and appreciated. Every little help counts,
so do not hesitate! You can make a high impact on xbitinfo just by using
it and reporting issues.
The following sections cover some general guidelines
regarding development in xbitinfo for maintainers and contributors.
Nothing here is set in stone and can’t be changed. Feel free to suggest improvements or changes in the workflow.
Feature requests and feedback#
We are eager to hear about your requests for new features and any suggestions
about the API, infrastructure, and so on. Feel free to submit these as
issues with the label
"enhancement".
Please make sure to explain in detail how the feature should work and keep the scope as narrow as possible. This will make it easier to implement in small PRs.
Report bugs#
Report bugs for xbitinfo in the
issue tracker with the
label “bug”.
If you are reporting a bug, please include:
Any details about your local setup that might be helpful in troubleshooting, specifically the Python interpreter version, installed libraries, and
xbitinfoversion.Detailed steps how to reproduce the bug <https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports>__
If you can write a demonstration test that currently fails but should pass, that is a very useful commit to make as well, even if you cannot fix the bug itself.
Bug Fix#
Look through the GitHub issues for bugs.
Talk to developers to find out how you can fix specific bugs.
Preparing Pull Requests#
Fork the xbitinfo GitHub repository. It’s fine to use
xbitinfoas your fork repository name because it will live under your user.Clone your fork locally using git, connect your repository to the upstream (main project), and create a branch:
$ git clone git@github.com:YOUR_GITHUB_USERNAME/xbitinfo.git $ cd xbitinfo $ git remote add upstream git@github.com:observingClouds/xbitinfo.git # now, to fix a bug or add feature create your own branch off "main": $ git checkout -b your-bugfix-feature-branch-name main
If you need some help with Git, follow this quick start guide.
Install dependencies using uv:
$ uv sync --group test
which will create a new virtual environment.
Install pre-commit and its hook on the
xbitinforepo:$ uvx pre-commit install
pre-commitautomatically beautifies the code, makes it more maintainable and catches syntax errors. Afterwardspre-commitwill run whenever you commit.Now you have an environment called
bitinfothat you can work in. You’ll need to make sure to activate that environment next time you want to use it after closing the terminal or your system.You can now edit your local working copy and run/add tests as necessary. Please try to follow PEP-8 for naming. When committing,
pre-commitwill modify the files as needed, or will generally be quite clear about what you need to do to pass the commit test.pre-commitalso runs:Break your edits up into reasonably sized commits:
$ git commit -m "<commit message>" $ git push -u
Run all tests
Once commits are pushed to
origin, GitHub Actions runs continuous integration of all tests with pytest on all new commits. However, you can already run tests locally:$ uv run pytest # all $ uv run pytest tests/test_bitround.py::test_xr_bitround_dask # specific tests
Check that doctests are passing:
$ uv run pytest --doctest-modules xbitinfo
Please stick to xarray’s testing recommendations.
Running the performance test suite
If you considerably changed to core of code of
xbitinfo, it is worth considering whether your code has introduced performance regressions.xbitinfohas a suite of benchmarking tests using asv to enable easy monitoring of the performance of criticalxbitinfooperations. These benchmarks are all found in theasv_benchdirectory.If you need to run a benchmark, change your directory to
asv_bench/and run:$ uv run asv continuous -f 1.1 upstream/main HEAD
You can replace
HEADwith the name of the branch you are working on, and report benchmarks that changed by more than 10%. The command usescondaby default for creating the benchmark environments.Running the full benchmark suite can take some time and use up a few GBs of RAM. Usually it is sufficient to paste only a subset of the results into the pull request to show that the committed changes do not cause unexpected performance regressions. If you want to only run a specific group of tests from a file, you can do it using
.as a separator. For example:$ uv run asv continuous -f 1.1 upstream/main HEAD -b benchmarks_bitround.rasm.time_xr_bitround
will only run the
time_xr_bitroundbenchmark of classrasmloading thexr.tutorial.load_dataset("rasm")defined inbenchmarks_bitround.py.Create a new changelog entry in CHANGELOG.rst:
The entry should be entered as:
<description>(:pr:`#<pull request number>`)`<author's names>`_where
<description>is the description of the PR related to the change and<pull request number>is the pull request number and<author's names>are your first and last names.Finally, submit a Pull Request through the GitHub website using this data:
head-fork: YOUR_GITHUB_USERNAME/xbitinfo compare: your-branch-name base-fork: observingClouds/xbitinfo base: main
Note that you can create the Pull Request while you’re working on this.
The PR will update as you add more commits. xbitinfo developers and
contributors can then review your code and offer suggestions.