Skip to content

Commit 608dfd9

Browse files
authored
Add an option to install with minimal dependencies (#4517)
1 parent 1cccbdd commit 608dfd9

7 files changed

Lines changed: 2002 additions & 150 deletions

File tree

.circleci/config.yml

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ jobs:
1414
- checkout
1515
- pixi/pixi_setup
1616
- run:
17-
name: Check dependencies are compatible
18-
command: pixi run --as-is pip check
17+
name: Check dependencies are compatible and installed
18+
command: |
19+
pixi run --as-is pip check
20+
# The following command should not install any new dependencies
21+
# because they are already in the conda environment, but this is
22+
# not checked.
23+
pixi run --as-is pip install --dry-run .[all]
1924
- run:
2025
name: Check code formatting and mistakes
2126
command: pixi run --as-is pre-commit run --all
@@ -49,35 +54,71 @@ jobs:
4954
- store_artifacts:
5055
path: test-reports.tar.gz
5156

57+
test_esmvaltool_base_installation:
58+
# Test running the example recipe with minimal dependencies.
59+
docker:
60+
- image: cimg/base:current
61+
resource_class: medium
62+
steps:
63+
- checkout
64+
- run:
65+
name: Generate cache key
66+
# Refresh the cache every month.
67+
command: echo $(date '+%Y-%m') | tee cache_key.txt
68+
- restore_cache:
69+
key: test-base-{{ .Branch }}-{{ checksum "cache_key.txt" }}
70+
- pixi/pixi_setup:
71+
env: esmvaltool-base
72+
- run:
73+
name: Check dependencies are compatible
74+
command: pixi run --as-is --environment esmvaltool-base pip check
75+
- run:
76+
name: Run example recipe
77+
command: |
78+
source <(pixi shell-hook --as-is --environment esmvaltool-base)
79+
esmvaltool version
80+
esmvaltool config copy data-intake-esgf.yml
81+
python -c '
82+
import intake_esgf
83+
intake_esgf.conf["solr_indices"]["esgf.ceda.ac.uk"] = True
84+
intake_esgf.conf["solr_indices"]["esgf-data.dkrz.de"] = True
85+
intake_esgf.conf.save()
86+
'
87+
esmvaltool run --max-parallel-tasks=2 testing/recipe_python_for_CI.yml
88+
- store_artifacts:
89+
path: /root/esmvaltool_output
90+
- save_cache:
91+
key: test-base-{{ .Branch }}-{{ checksum "cache_key.txt" }}
92+
paths:
93+
- /root/climate_data
94+
5295
test_upstream_development:
5396
# Test running recipes with the development version of ESMValCore. The
5497
# purpose of this test to discover backward-incompatible changes early on in
5598
# the development cycle.
5699
docker:
57100
- image: cimg/base:current
58-
resource_class: large
101+
resource_class: medium
59102
steps:
60103
- checkout
61104
- run:
62105
name: Generate cache key
63-
command: echo $(date '+%Y')-$(expr $(date '+%V') / 2) | tee cache_key.txt
106+
# Refresh the cache every month.
107+
command: echo $(date '+%Y-%m') | tee cache_key.txt
64108
- restore_cache:
65109
key: test-upstream-{{ .Branch }}-{{ checksum "cache_key.txt" }}
66110
- pixi/pixi_setup:
67111
env: esmvalcore-dev
68112
- run:
69113
name: Run tests
70114
command: |
71-
pixi run --as-is --environment esmvalcore-dev test -n 4 --junitxml=test-reports/report.xml
115+
pixi run --as-is --environment esmvalcore-dev test -n 2 --junitxml=test-reports/report.xml
72116
- store_test_results:
73117
path: test-reports/report.xml
74118
- run:
75119
name: Run recipes
76120
command: |
77121
source <(pixi shell-hook --as-is --environment esmvalcore-dev)
78-
# Temporarily install intake-esgf here until there is a new release
79-
# that includes https://github.com/esgf2-us/intake-esgf/pull/160.
80-
pip install git+https://github.com/esgf2-us/intake-esgf@main
81122
esmvaltool version
82123
esmvaltool config copy data-intake-esgf.yml
83124
python -c '
@@ -100,7 +141,7 @@ jobs:
100141
# Test building documentation
101142
docker:
102143
- image: cimg/base:current
103-
resource_class: medium+
144+
resource_class: medium
104145
steps:
105146
- checkout
106147
- pixi/pixi_setup
@@ -148,6 +189,7 @@ workflows:
148189
- main
149190
jobs:
150191
- tests
192+
- test_esmvaltool_base_installation
151193
- test_upstream_development
152194
- build_documentation
153195
- test_installation_from_conda

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ jobs:
3232
- test-py312
3333
- test-py313
3434
- test-py314
35+
- esmvaltool-base-dev
3536
name: ${{ matrix.os }} ${{ matrix.environment }}
3637
steps:
3738
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
3839
with:
3940
fetch-depth: 0
4041
persist-credentials: false
41-
- uses: prefix-dev/setup-pixi@5185adfbffb4bd703da3010310260805d89ebb11 # v0.9.6
42+
- uses: prefix-dev/setup-pixi@5185adfbffb4bd703da3010310260805d89ebb11 # v0.9.6
4243
with:
4344
frozen: true
4445
environments: ${{ matrix.environment }}
@@ -47,7 +48,15 @@ jobs:
4748
- name: Check code quality
4849
run: pre-commit run -a
4950
- name: Run tests
50-
run: pytest -n 2 -m "not installation"
51+
if: matrix.environment != 'esmvaltool-base-dev'
52+
run: pytest -n 2
53+
- name: Run tests
54+
if: matrix.environment == 'esmvaltool-base-dev'
55+
run: >-
56+
pytest
57+
-n 2
58+
--ignore=tests/sample_data/
59+
--ignore=tests/unit/cmorizers/test_cmorization_interface.py
5160
- name: Upload artifacts
5261
if: ${{ always() }} # upload artifacts even if fail
5362
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

doc/sphinx/source/community/code_documentation.rst

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -522,22 +522,42 @@ See this `statement <https://www.apache.org/licenses/GPL-compatibility.html>`__
522522
by the authors of the Apache 2.0 license for more information.
523523

524524
When adding or removing dependencies, please consider applying the changes in
525-
the following locations in ``pyproject.toml``:
525+
the following two locations in ``pyproject.toml``:
526526

527-
- ``dependencies``
528-
contains dependencies that can be installed from `PyPI <https://pypi.org/>`__
529-
- ``[tool.pixi.dependencies]``
530-
contains dependencies that can be installed from `conda-forge <https://conda-forge.org/>`__
527+
- ``[project.optional-dependencies]``
528+
the ``all`` item contains all dependencies needed to run the diagnostics
529+
and CMORizer scripts, with the names used on `PyPI <https://pypi.org/>`__.
530+
- ``[tool.pixi.feature.all]``
531+
the same list of dependencies as under ``[project.optional-dependencies]``,
532+
but with the names used on `conda-forge <https://conda-forge.org/>`__.
531533

532534
It is strongly preferred that those two lists are kept in sync, apart from
533535
differences in how packages are named. Run the command ``pixi lock --no-install``
534536
after making changes to the dependencies to update the ``pixi.lock`` file, which
535537
is used to make sure that the same versions of packages are installed for
536538
all ESMValTool developers.
537539

538-
In addition to these core dependencies, there are also optional dependencies
539-
for diagnostics that need R or NCL. These are listed in the sections
540-
``[tool.pixi.feature.r]`` and ``[tool.pixi.feature.ncl]`` in respectively.
540+
There is also a minimal set of dependencies that are required to run the example
541+
recipe ``examples/recipe_python.yml``. Please do not add new dependencies to
542+
this list unless they are really needed to support the core functionality of
543+
ESMValTool. These can be used by users who want to run ESMValTool with a minimal
544+
set of dependencies and want to manage which dependencies of diagnostics and/or
545+
CMORizer scripts get installed themselves. The minimal dependencies are listed
546+
in the following two locations in ``pyproject.toml``:
547+
548+
- ``dependencies``
549+
contains a minimal set of dependencies, those required to run the example
550+
recipe, with the names used on `PyPI <https://pypi.org/>`__
551+
- ``[tool.pixi.dependencies]``
552+
the same list of dependencies as under ``dependencies``, but with the names
553+
used on `conda-forge <https://conda-forge.org/>`__
554+
555+
It is strongly preferred that those two lists are kept in sync, apart from
556+
differences in how packages are named.
557+
558+
In addition to the core dependencies mentioned above, there are further optional
559+
dependencies for diagnostics that need R or NCL. These are listed in the sections
560+
``[tool.pixi.feature.r]`` and ``[tool.pixi.feature.ncl]`` respectively.
541561

542562
There are also three feature groups for development dependencies:
543563

doc/sphinx/source/quickstart/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ message to the console.
165165
Installation of subpackages
166166
---------------------------
167167

168-
The diagnostics bundled in ESMValTool are scripts in four different programming
169-
languages: Python, NCL, and R.
168+
The diagnostics bundled in ESMValTool are scripts in three different programming
169+
languages: Python, R, and NCL.
170170

171171
There are three language specific packages available:
172172

173-
* ``esmvaltool-ncl``
174173
* ``esmvaltool-python``
175174
* ``esmvaltool-r``
175+
* ``esmvaltool-ncl``
176176

177177
The main ``esmvaltool`` package contains all three subpackages listed above.
178178
If you only need to run a recipe with diagnostics in some of these languages, it

0 commit comments

Comments
 (0)