1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
============
Contributing
============
Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
You can contribute in many ways:
Report Bugs
===========
Report bugs at https://github.com/opencobra/cobrapy/issues.
If you are reporting a bug, please follow the template guide lines. The more
detailed your report, the easier and thus faster we can help you.
Fix Bugs
========
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Implement Features
==================
Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.
Write Documentation
===================
cobrapy could always use more documentation, whether as part of the official
documentation, in docstrings, or even on the web in blog posts, articles, and
such.
Submit Feedback
===============
The best way to send feedback is to file an issue at
https://github.com/opencobra/cobrapy/issues.
If you are proposing a feature:
* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions are
welcome :)
Get Started!
============
Ready to contribute? Here's how to set up cobrapy for local development.
1. Fork the https://github.com/opencobra/cobrapy repository on GitHub. If you
have never done this before, `follow the official guide
<https://guides.github.com/activities/forking/>`_
2. Clone your fork locally as described in the same guide.
3. Install your local copy into a a Python virtual environment. You can `read
this guide to learn more
<https://realpython.com/python-virtual-environments-a-primer/>`_ about them
and how to create one. Alternatively, particularly if you are a Windows or
Mac user, you can also use `Anaconda <https://docs.anaconda.com/anaconda/>`_.
Assuming you have virtualenvwrapper installed, this is how you set up your
fork for local development
.. code-block:: console
mkvirtualenv my-env
cd cobrapy/
pip install -e ".[development]"
4. Create a branch for local development using the ``devel`` branch as a
starting point. Use ``fix``, ``refactor``, or ``feat`` as a prefix
.. code-block:: console
git checkout devel
git checkout -b fix-name-of-your-bugfix
Now you can make your changes locally.
5. When making changes locally, it is helpful to ``git commit`` your work
regularly. On one hand to save your work and on the other hand, the smaller
the steps, the easier it is to review your work later. Please use `semantic
commit messages
<http://karma-runner.github.io/2.0/dev/git-commit-msg.html>`_.
.. code-block:: console
git add .
git commit -m "fix: Your summary of changes"
6. When you're done making changes, check that your changes pass our test suite.
This is all included with tox
.. code-block:: console
tox
You can also run all ``tox`` tests in parallel. As of ``tox 3.7``, you can run
.. code-block:: console
tox --parallel
7. Push your branch to GitHub.
.. code-block:: console
git push origin fix-name-of-your-bugfix
8. Open the link displayed in the message when pushing your new branch in order
to submit a pull request. Please follow the template presented to you in the
web interface to complete your pull request.
For larger features that you want to work on collaboratively with other cobrapy
team members, you may consider to first request to join the cobrapy developers
team to get write access to the repository so that you can create a branch in
the main repository (or simply ask the maintainer to create a branch for you).
Once you have a new branch you can push your changes directly to the main
repository and when finished, submit a pull request from that branch to
``devel``.
Pull Request Guidelines
-----------------------
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests in the ``cobra/test``
directory. Except in rare circumstances, code coverage must
not decrease (as reported by codecov which runs automatically when
you submit your pull request)
2. If the pull request adds functionality, the docs should be
updated. Put your new functionality into a function with a
docstring and consider creating a notebook that demonstrates the
usage in ``documentation_builder`` (documentation is written as
jupyter notebooks in the ``documentation_builder`` directory, which
are then converted to rst by the ``autodoc.sh`` script.)
3. The pull request will be tested for several different Python versions.
4. Someone from the @opencobra/cobrapy-core team will review your work and guide
you to a successful contribution.
Unit tests and benchmarks
-------------------------
cobrapy uses `pytest <http://docs.pytest.org/en/latest/>`_ for its
unit-tests and new features should in general always come with new
tests that make sure that the code runs as intended. Since COBRA
rapidly can become quite resource intensive fundamental methods such
as model manipulation, adding and removing reactions, metabolites etc
also must work efficiently. We use `pytest-benchmark
<https://pytest-benchmark.readthedocs.io/en/latest/>`_ to compare
different implementations to make sure that new code do not come with
unacceptable increased computation time. If you add benchmarked tests,
make sure to also include a test with and without the benchmark as we
do not want to slow down continuous integration by running benchmarks,
for examples, see e.g. ``test_add_metabolite`` in `test_model.py
<cobra/test/test_model.py>`_. ``test_add_metabolite`` is the main
test, ``test_add_metabolite_benchmark`` takes the special
``benchmark`` fixture that enables profiling the important code
snippet but is skipped when running::
(cobrapy)$ pytest --benchmark-skip
When the test function itself is small and can safely be assumed to
not take many resources, we can directly profile the test as in
``test_subtract_metabolite_benchmark`` which calls
``benchmark(self.test_subtract_metabolite, model)``.
To run all tests and benchmarks do::
(cobrapy)$ pytest
and to compare two implementations you may keep them in two branches
e.g. ``old`` and ``new`` and then do::
(cobrapy)$ git checkout old
(cobrapy)$ pytest --benchmark-save
(cobrapy)$ git checkout new
(cobrapy)$ pytest --benchmark-compare
Branching model
---------------
``devel``
Is the branch all pull-requests should be based on.
``stable``
Is only touched by maintainers and is the branch with only tested, reviewed
code that is released or ready for the next release.
``{fix, bugfix, doc, feature}/descriptive-name``
Is the recommended naming scheme for smaller improvements, bugfixes,
documentation improvement and new features respectively.
Please use concise descriptive commit messages and consider using
``git pull --rebase`` when you update your own fork to avoid merge commits.
Thank you very much for contributing to cobrapy!
FAQs
----
Q1. Why do all of the tests that involve loading a pickled model fail on my branch?
A: Pickling is the standard method for serializing objects in python,
which is commonly done during operations like multiprocessing.
Because of this, we need to maintain tests that run on pickled
models, otherwise contributors may inadvertantly break
multiprocessing features. If changes you made to cobrapy
modify attributes of the ``cobra.Model`` class, the pickled
models stored in the repository won't contain those changes
and may fail tests that you add or modify. To resolve these
errors, just run ``cobra/test/data/update_pickles.py`` on your
branch, which will repickle the models.
|