Skip to content

Commit 821563a

Browse files
authored
Merge pull request #1440 from MetOffice/776_document_adding_a_new_dependency
Document how to add new dependencies to CSET
2 parents c821533 + 49e8671 commit 821563a

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Dependencies
2+
============
3+
4+
Requirements of a new dependency
5+
--------------------------------
6+
7+
Dependencies should be sufficiently maintained before being added to CSET. This
8+
is typically observed through recent and regular activity on the source
9+
repository, especially from multiple people. The dependency should be adding a
10+
valuable capability to justify the potential cost of us having to maintain or
11+
replace it in future.
12+
13+
Finally dependencies must be published under an open source licence that is
14+
compatible with CSET's, and be distributed via conda-forge.
15+
16+
Adding a new dependency
17+
-----------------------
18+
19+
While a single ``conda install <package>`` can be used to experiment with an
20+
additional dependency, to properly include it in CSET it needs to be added to a
21+
number of files.
22+
23+
Specifically it needs to be added to the ``pyproject.toml`` under the
24+
"dependencies" key, and ``requirements/environment.yaml`` under the appropriate
25+
dependencies section.
26+
27+
After updating those two files and making a pull request, you'll need to rerun
28+
the conda lockfile generation action. In `Actions > Update conda lock files >
29+
Run workflow`_ select your branch, then run the workflow. A new PR will be
30+
created to update the lockfiles, which you can merge into your own branch.
31+
32+
.. _Actions > Update conda lock files > Run workflow: https://github.com/MetOffice/CSET/actions/workflows/conda-lock.yml
33+
34+
Updating the conda-forge package
35+
--------------------------------
36+
37+
Conda packages are built from "feedstocks", which are repositories that contain
38+
the list of steps to build, package, and test the package, as well as the
39+
required metadata, such as the package name, and needed dependencies.
40+
41+
The CSET feedstock is at `github.com/conda-forge/cset-feedstock`_. The only user
42+
editable file in this repository is `recipe/recipe.yaml`_. All of the other
43+
files are either automatically generated from the recipe file, or are inert
44+
things that don't affect the resultant package, like the README.
45+
46+
In this case we care about the runtime dependencies in `recipe/recipe.yaml`_:
47+
48+
`Lines 27 to 37 in commit 805148a`_:
49+
50+
.. code-block:: yaml
51+
52+
run:
53+
- python >=${{ python_min }}
54+
- numpy
55+
- iris >=3.12.2
56+
- ruamel.yaml >=0.17
57+
- pygraphviz >=1.11
58+
- mo_pack >=0.3
59+
- isodate >=0.6
60+
- markdown-it-py >=3.0
61+
- nc-time-axis
62+
- iris-grib
63+
64+
Because this repository is not within the MetOffice GitHub organisation, we
65+
cannot directly change it. We have to make a `fork of the repository`_ to make
66+
changes. Once you have created a fork, you can edit the feedstock recipe and
67+
make the needed changes. In this case we need two changes.
68+
69+
1. Add the new dependency under the runtime requirements section. Remember to
70+
use the conda-forge package name!
71+
72+
.. code-block:: yaml
73+
74+
requirements:
75+
run:
76+
- my_dependency
77+
78+
2. Increase the `build number`_. This is used when the package version does not
79+
increase, so conda knows which version is more up-to-date.
80+
81+
Finally make your pull request, the `feedstock maintainer`_ will review and merge
82+
it, and soon after your updated package will be published on conda-forge.
83+
84+
.. _github.com/conda-forge/cset-feedstock: https://github.com/conda-forge/cset-feedstock
85+
.. _recipe/recipe.yaml: https://github.com/conda-forge/cset-feedstock/blob/main/recipe/recipe.yaml
86+
.. _Lines 27 to 37 in commit 805148a: https://github.com/conda-forge/cset-feedstock/blob/805148a2191e1256667fb74f8e5b051f6339af56/recipe/recipe.yaml#L27-L37
87+
.. _fork of the repository: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo
88+
.. _build number: https://github.com/conda-forge/cset-feedstock/blob/805148a2191e1256667fb74f8e5b051f6339af56/recipe/recipe.yaml#L14
89+
.. _feedstock maintainer: https://github.com/conda-forge/cset-feedstock?tab=readme-ov-file#feedstock-maintainers

docs/source/contributing/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ need to get started, and the links below go into more detail on specific topics.
1313
testing
1414
documentation
1515
code-review
16+
dependencies
1617
releases
1718

1819
Contributing checklist

0 commit comments

Comments
 (0)