climate-ref 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- climate_ref-0.5.0/.gitignore +161 -0
- climate_ref-0.5.0/Dockerfile +56 -0
- climate_ref-0.5.0/LICENCE +201 -0
- climate_ref-0.5.0/NOTICE +3 -0
- climate_ref-0.5.0/PKG-INFO +97 -0
- climate_ref-0.5.0/README.md +56 -0
- climate_ref-0.5.0/conftest.py +88 -0
- climate_ref-0.5.0/pyproject.toml +67 -0
- climate_ref-0.5.0/src/climate_ref/__init__.py +30 -0
- climate_ref-0.5.0/src/climate_ref/_config_helpers.py +214 -0
- climate_ref-0.5.0/src/climate_ref/alembic.ini +114 -0
- climate_ref-0.5.0/src/climate_ref/cli/__init__.py +138 -0
- climate_ref-0.5.0/src/climate_ref/cli/_utils.py +68 -0
- climate_ref-0.5.0/src/climate_ref/cli/config.py +28 -0
- climate_ref-0.5.0/src/climate_ref/cli/datasets.py +205 -0
- climate_ref-0.5.0/src/climate_ref/cli/executions.py +201 -0
- climate_ref-0.5.0/src/climate_ref/cli/providers.py +84 -0
- climate_ref-0.5.0/src/climate_ref/cli/solve.py +23 -0
- climate_ref-0.5.0/src/climate_ref/config.py +475 -0
- climate_ref-0.5.0/src/climate_ref/constants.py +8 -0
- climate_ref-0.5.0/src/climate_ref/database.py +223 -0
- climate_ref-0.5.0/src/climate_ref/dataset_registry/obs4ref_reference.txt +2 -0
- climate_ref-0.5.0/src/climate_ref/dataset_registry/sample_data.txt +60 -0
- climate_ref-0.5.0/src/climate_ref/datasets/__init__.py +40 -0
- climate_ref-0.5.0/src/climate_ref/datasets/base.py +214 -0
- climate_ref-0.5.0/src/climate_ref/datasets/cmip6.py +202 -0
- climate_ref-0.5.0/src/climate_ref/datasets/obs4mips.py +224 -0
- climate_ref-0.5.0/src/climate_ref/datasets/pmp_climatology.py +15 -0
- climate_ref-0.5.0/src/climate_ref/datasets/utils.py +16 -0
- climate_ref-0.5.0/src/climate_ref/executor/__init__.py +274 -0
- climate_ref-0.5.0/src/climate_ref/executor/local.py +89 -0
- climate_ref-0.5.0/src/climate_ref/migrations/README +22 -0
- climate_ref-0.5.0/src/climate_ref/migrations/env.py +139 -0
- climate_ref-0.5.0/src/climate_ref/migrations/script.py.mako +26 -0
- climate_ref-0.5.0/src/climate_ref/migrations/versions/2025-05-02T1418_341a4aa2551e_regenerate.py +292 -0
- climate_ref-0.5.0/src/climate_ref/models/__init__.py +33 -0
- climate_ref-0.5.0/src/climate_ref/models/base.py +42 -0
- climate_ref-0.5.0/src/climate_ref/models/dataset.py +206 -0
- climate_ref-0.5.0/src/climate_ref/models/diagnostic.py +61 -0
- climate_ref-0.5.0/src/climate_ref/models/execution.py +306 -0
- climate_ref-0.5.0/src/climate_ref/models/metric_value.py +195 -0
- climate_ref-0.5.0/src/climate_ref/models/provider.py +39 -0
- climate_ref-0.5.0/src/climate_ref/provider_registry.py +146 -0
- climate_ref-0.5.0/src/climate_ref/py.typed +0 -0
- climate_ref-0.5.0/src/climate_ref/solver.py +395 -0
- climate_ref-0.5.0/src/climate_ref/testing.py +109 -0
- climate_ref-0.5.0/tests/unit/cli/test_config.py +38 -0
- climate_ref-0.5.0/tests/unit/cli/test_datasets.py +245 -0
- climate_ref-0.5.0/tests/unit/cli/test_executions/test_inspect.txt +27 -0
- climate_ref-0.5.0/tests/unit/cli/test_executions.py +148 -0
- climate_ref-0.5.0/tests/unit/cli/test_providers.py +23 -0
- climate_ref-0.5.0/tests/unit/cli/test_root.py +91 -0
- climate_ref-0.5.0/tests/unit/cli/test_solve.py +30 -0
- climate_ref-0.5.0/tests/unit/datasets/conftest.py +13 -0
- climate_ref-0.5.0/tests/unit/datasets/test_cmip6/cmip6_catalog_db.yml +1932 -0
- climate_ref-0.5.0/tests/unit/datasets/test_cmip6/cmip6_catalog_local.yml +1987 -0
- climate_ref-0.5.0/tests/unit/datasets/test_cmip6.py +96 -0
- climate_ref-0.5.0/tests/unit/datasets/test_datasets.py +100 -0
- climate_ref-0.5.0/tests/unit/datasets/test_obs4mips/obs4mips_catalog_db.yml +60 -0
- climate_ref-0.5.0/tests/unit/datasets/test_obs4mips/obs4mips_catalog_local.yml +21 -0
- climate_ref-0.5.0/tests/unit/datasets/test_obs4mips.py +140 -0
- climate_ref-0.5.0/tests/unit/datasets/test_pmp_climatology/pmp_catalog_local.yml +21 -0
- climate_ref-0.5.0/tests/unit/datasets/test_pmp_climatology.py +46 -0
- climate_ref-0.5.0/tests/unit/datasets/test_utils.py +36 -0
- climate_ref-0.5.0/tests/unit/executor/test_executor.py +200 -0
- climate_ref-0.5.0/tests/unit/executor/test_local_executor.py +49 -0
- climate_ref-0.5.0/tests/unit/models/test_metric_execution.py +38 -0
- climate_ref-0.5.0/tests/unit/models/test_metric_value.py +67 -0
- climate_ref-0.5.0/tests/unit/test_config.py +228 -0
- climate_ref-0.5.0/tests/unit/test_database.py +150 -0
- climate_ref-0.5.0/tests/unit/test_provider_registry.py +16 -0
- climate_ref-0.5.0/tests/unit/test_solver/test_solve_metrics.yml +40 -0
- climate_ref-0.5.0/tests/unit/test_solver.py +596 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Notebooks
|
|
2
|
+
*.ipynb
|
|
3
|
+
|
|
4
|
+
# Databases
|
|
5
|
+
*.db
|
|
6
|
+
|
|
7
|
+
# Jupyter cache
|
|
8
|
+
.jupyter_cache
|
|
9
|
+
|
|
10
|
+
# IDE stuff
|
|
11
|
+
.idea/
|
|
12
|
+
|
|
13
|
+
# Ruff cache
|
|
14
|
+
.ruff_cache
|
|
15
|
+
|
|
16
|
+
# Licence check
|
|
17
|
+
licence-check.txt
|
|
18
|
+
|
|
19
|
+
# Byte-compiled / optimized / DLL files
|
|
20
|
+
__pycache__/
|
|
21
|
+
*.py[cod]
|
|
22
|
+
*$py.class
|
|
23
|
+
|
|
24
|
+
# C extensions
|
|
25
|
+
*.so
|
|
26
|
+
|
|
27
|
+
# Distribution / packaging
|
|
28
|
+
.Python
|
|
29
|
+
build/
|
|
30
|
+
develop-eggs/
|
|
31
|
+
dist/
|
|
32
|
+
downloads/
|
|
33
|
+
eggs/
|
|
34
|
+
.eggs/
|
|
35
|
+
lib/
|
|
36
|
+
lib64/
|
|
37
|
+
parts/
|
|
38
|
+
sdist/
|
|
39
|
+
var/
|
|
40
|
+
wheels/
|
|
41
|
+
pip-wheel-metadata/
|
|
42
|
+
share/python-wheels/
|
|
43
|
+
*.egg-info/
|
|
44
|
+
.installed.cfg
|
|
45
|
+
*.egg
|
|
46
|
+
MANIFEST
|
|
47
|
+
|
|
48
|
+
# PyInstaller
|
|
49
|
+
# Usually these files are written by a python script from a template
|
|
50
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
51
|
+
*.manifest
|
|
52
|
+
*.spec
|
|
53
|
+
|
|
54
|
+
# Installer logs
|
|
55
|
+
pip-log.txt
|
|
56
|
+
pip-delete-this-directory.txt
|
|
57
|
+
|
|
58
|
+
# Unit test / coverage reports
|
|
59
|
+
htmlcov/
|
|
60
|
+
.tox/
|
|
61
|
+
.nox/
|
|
62
|
+
.coverage
|
|
63
|
+
.coverage.*
|
|
64
|
+
.cache
|
|
65
|
+
nosetests.xml
|
|
66
|
+
coverage.xml
|
|
67
|
+
*.cover
|
|
68
|
+
*.py,cover
|
|
69
|
+
.hypothesis/
|
|
70
|
+
.pytest_cache/
|
|
71
|
+
|
|
72
|
+
# Translations
|
|
73
|
+
*.mo
|
|
74
|
+
*.pot
|
|
75
|
+
|
|
76
|
+
# Django stuff:
|
|
77
|
+
*.log
|
|
78
|
+
local_settings.py
|
|
79
|
+
db.sqlite3
|
|
80
|
+
db.sqlite3-journal
|
|
81
|
+
|
|
82
|
+
# Flask stuff:
|
|
83
|
+
instance/
|
|
84
|
+
.webassets-cache
|
|
85
|
+
|
|
86
|
+
# Scrapy stuff:
|
|
87
|
+
.scrapy
|
|
88
|
+
|
|
89
|
+
# Sphinx documentation
|
|
90
|
+
docs/_build/
|
|
91
|
+
|
|
92
|
+
# PyBuilder
|
|
93
|
+
target/
|
|
94
|
+
|
|
95
|
+
# Jupyter Notebook
|
|
96
|
+
.ipynb_checkpoints
|
|
97
|
+
|
|
98
|
+
# IPython
|
|
99
|
+
profile_default/
|
|
100
|
+
ipython_config.py
|
|
101
|
+
|
|
102
|
+
# pipenv
|
|
103
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
104
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
105
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
106
|
+
# install all needed dependencies.
|
|
107
|
+
#Pipfile.lock
|
|
108
|
+
|
|
109
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
110
|
+
__pypackages__/
|
|
111
|
+
|
|
112
|
+
# Celery stuff
|
|
113
|
+
celerybeat-schedule
|
|
114
|
+
celerybeat.pid
|
|
115
|
+
|
|
116
|
+
# SageMath parsed files
|
|
117
|
+
*.sage.py
|
|
118
|
+
|
|
119
|
+
# Environments
|
|
120
|
+
.env
|
|
121
|
+
.venv
|
|
122
|
+
env/
|
|
123
|
+
venv/
|
|
124
|
+
ENV/
|
|
125
|
+
env.bak/
|
|
126
|
+
venv.bak/
|
|
127
|
+
|
|
128
|
+
# Spyder project settings
|
|
129
|
+
.spyderproject
|
|
130
|
+
.spyproject
|
|
131
|
+
|
|
132
|
+
# Rope project settings
|
|
133
|
+
.ropeproject
|
|
134
|
+
|
|
135
|
+
# mkdocs documentation
|
|
136
|
+
/site
|
|
137
|
+
|
|
138
|
+
# mypy
|
|
139
|
+
.mypy_cache/
|
|
140
|
+
.dmypy.json
|
|
141
|
+
dmypy.json
|
|
142
|
+
|
|
143
|
+
# Pyre type checker
|
|
144
|
+
.pyre/
|
|
145
|
+
|
|
146
|
+
# Mac stuff
|
|
147
|
+
*.DS_Store
|
|
148
|
+
|
|
149
|
+
# Esgpull
|
|
150
|
+
.esgpull
|
|
151
|
+
|
|
152
|
+
# Generated output
|
|
153
|
+
out
|
|
154
|
+
.ref
|
|
155
|
+
|
|
156
|
+
# Ignore copied LICENCE/NOTICE files
|
|
157
|
+
packages/*/LICENCE
|
|
158
|
+
packages/*/NOTICE
|
|
159
|
+
|
|
160
|
+
# Local directory for data
|
|
161
|
+
/data
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Build the container for the the REF compute engine
|
|
2
|
+
# This docker container packages up the REF cli tool with the default set of diagnostic providers
|
|
3
|
+
# used as part of the CMIP7 FastTrack process.
|
|
4
|
+
|
|
5
|
+
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS build
|
|
6
|
+
|
|
7
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
8
|
+
git \
|
|
9
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
10
|
+
|
|
11
|
+
# Enable bytecode compilation
|
|
12
|
+
ENV UV_COMPILE_BYTECODE=1
|
|
13
|
+
|
|
14
|
+
# Copy from the cache instead of linking since it's a mounted volume
|
|
15
|
+
ENV UV_LINK_MODE=copy
|
|
16
|
+
|
|
17
|
+
WORKDIR /app
|
|
18
|
+
|
|
19
|
+
# Install the project's dependencies using the lockfile and settings
|
|
20
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
21
|
+
--mount=type=bind,source=uv.lock,target=uv.lock \
|
|
22
|
+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
|
23
|
+
uv sync --frozen --no-install-workspace --no-editable --no-dev
|
|
24
|
+
|
|
25
|
+
# Then, add the rest of the project source code and install it
|
|
26
|
+
# Installing separately from its dependencies allows optimal layer caching
|
|
27
|
+
ADD . /app
|
|
28
|
+
|
|
29
|
+
# Sync the project as non-editable installs
|
|
30
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
31
|
+
uv sync --frozen --no-editable --no-dev
|
|
32
|
+
|
|
33
|
+
# Runtime container
|
|
34
|
+
# Copy the installed packages from the build stage to decrease the size of the final image
|
|
35
|
+
FROM python:3.11-slim AS runtime
|
|
36
|
+
|
|
37
|
+
LABEL maintainer="Jared Lewis <jared.lewis@climate-resource.com>"
|
|
38
|
+
LABEL description="Docker image for the REF compute engine"
|
|
39
|
+
|
|
40
|
+
# Allow celery to run as root
|
|
41
|
+
ENV C_FORCE_ROOT=false
|
|
42
|
+
ENV PATH="/app/.venv/bin:${PATH}"
|
|
43
|
+
|
|
44
|
+
# Copy the installed packages from the build stage
|
|
45
|
+
COPY --from=build --chown=app:app /app/.venv /app/.venv
|
|
46
|
+
COPY --from=build --chown=app:app /app/scripts /app/scripts
|
|
47
|
+
|
|
48
|
+
# Location of the REF configuration files
|
|
49
|
+
ENV REF_CONFIGURATION=/ref
|
|
50
|
+
ENV REF_METRICS_ESMVALTOOL_DATA_DIR=/app/cache/esmvaltool
|
|
51
|
+
|
|
52
|
+
#RUN ref datasets fetch-data --registry ilamb
|
|
53
|
+
#RUN ref datasets fetch-data --registry iomb
|
|
54
|
+
|
|
55
|
+
# Run the REF CLI tool by default
|
|
56
|
+
ENTRYPOINT ["/app/.venv/bin/ref"]
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
climate_ref-0.5.0/NOTICE
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: climate-ref
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Application which runs the CMIP Rapid Evaluation Framework
|
|
5
|
+
Author-email: Jared Lewis <jared.lewis@climate-resource.com>, Mika Pflueger <mika.pflueger@climate-resource.com>, Bouwe Andela <b.andela@esciencecenter.nl>, Jiwoo Lee <lee1043@llnl.gov>, Min Xu <xum1@ornl.gov>, Nathan Collier <collierno@ornl.gov>, Dora Hegedus <dora.hegedus@stfc.ac.uk>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
License-File: LICENCE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: alembic>=1.13.3
|
|
21
|
+
Requires-Dist: attrs>=24.2.0
|
|
22
|
+
Requires-Dist: cattrs>=24.1.2
|
|
23
|
+
Requires-Dist: climate-ref-core
|
|
24
|
+
Requires-Dist: ecgtools>=2024.7.31
|
|
25
|
+
Requires-Dist: environs>=11.0.0
|
|
26
|
+
Requires-Dist: loguru>=0.7.2
|
|
27
|
+
Requires-Dist: platformdirs>=4.3.6
|
|
28
|
+
Requires-Dist: setuptools>=75.8.0
|
|
29
|
+
Requires-Dist: sqlalchemy>=2.0.36
|
|
30
|
+
Requires-Dist: tomlkit>=0.13.2
|
|
31
|
+
Requires-Dist: typer>=0.12.5
|
|
32
|
+
Provides-Extra: celery
|
|
33
|
+
Requires-Dist: climate-ref-celery>=0.5.0; extra == 'celery'
|
|
34
|
+
Provides-Extra: metrics
|
|
35
|
+
Requires-Dist: climate-ref-esmvaltool>=0.5.0; extra == 'metrics'
|
|
36
|
+
Requires-Dist: climate-ref-ilamb>=0.5.0; extra == 'metrics'
|
|
37
|
+
Requires-Dist: climate-ref-pmp>=0.5.0; extra == 'metrics'
|
|
38
|
+
Provides-Extra: postgres
|
|
39
|
+
Requires-Dist: psycopg2-binary>=2.9.2; extra == 'postgres'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# Climate REF (Rapid Evaluation Framework)
|
|
43
|
+
|
|
44
|
+
[](https://badge.fury.io/py/climate-ref)
|
|
45
|
+
[](https://climate-ref.readthedocs.io/en/latest/?badge=latest)
|
|
46
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
|
|
49
|
+
**Status**: This project is in active development. We expect to be ready for beta releases in Q2 2025.
|
|
50
|
+
|
|
51
|
+
The Rapid Evaluation Framework (REF) is a set of Python packages that provide the ability to manage the execution of calculations against climate datasets.
|
|
52
|
+
The aim is to be able to evaluate climate data against a set of reference data in near-real time as datasets are published,
|
|
53
|
+
and to update any produced data and figures as new datasets become available.
|
|
54
|
+
This is somewhat analogous to a CI/CD pipeline for climate data.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install climate-ref
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you want to use the diagnostic providers for the Assessment Fast Track, you can install them with:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install climate-ref[metrics]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Ingest some observation datasets
|
|
72
|
+
ref datasets fetch-data --registry obs4ref --output-dir datasets/obs4ref
|
|
73
|
+
ref datasets fetch-data --registry sample-data --output-dir datasets/sample-data
|
|
74
|
+
|
|
75
|
+
# Run metrics against your climate data
|
|
76
|
+
ref solve
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
- Real-time evaluation of climate datasets
|
|
82
|
+
- Support for multiple metrics providers (PMP, ILAMB, ESMValTool)
|
|
83
|
+
- Distributed processing capabilities
|
|
84
|
+
- Extensible architecture for adding new metrics providers
|
|
85
|
+
- Command-line interface for easy interaction
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
For detailed documentation, please visit [https://climate-ref.readthedocs.io/](https://climate-ref.readthedocs.io/)
|
|
90
|
+
|
|
91
|
+
## Contributing
|
|
92
|
+
|
|
93
|
+
REF is a community project, and we welcome contributions from anyone. Please see our [Contributing Guide](https://climate-ref.readthedocs.io/en/latest/contributing/) for more information.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Climate REF (Rapid Evaluation Framework)
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/climate-ref)
|
|
4
|
+
[](https://climate-ref.readthedocs.io/en/latest/?badge=latest)
|
|
5
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
|
|
8
|
+
**Status**: This project is in active development. We expect to be ready for beta releases in Q2 2025.
|
|
9
|
+
|
|
10
|
+
The Rapid Evaluation Framework (REF) is a set of Python packages that provide the ability to manage the execution of calculations against climate datasets.
|
|
11
|
+
The aim is to be able to evaluate climate data against a set of reference data in near-real time as datasets are published,
|
|
12
|
+
and to update any produced data and figures as new datasets become available.
|
|
13
|
+
This is somewhat analogous to a CI/CD pipeline for climate data.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install climate-ref
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If you want to use the diagnostic providers for the Assessment Fast Track, you can install them with:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install climate-ref[metrics]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Ingest some observation datasets
|
|
31
|
+
ref datasets fetch-data --registry obs4ref --output-dir datasets/obs4ref
|
|
32
|
+
ref datasets fetch-data --registry sample-data --output-dir datasets/sample-data
|
|
33
|
+
|
|
34
|
+
# Run metrics against your climate data
|
|
35
|
+
ref solve
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- Real-time evaluation of climate datasets
|
|
41
|
+
- Support for multiple metrics providers (PMP, ILAMB, ESMValTool)
|
|
42
|
+
- Distributed processing capabilities
|
|
43
|
+
- Extensible architecture for adding new metrics providers
|
|
44
|
+
- Command-line interface for easy interaction
|
|
45
|
+
|
|
46
|
+
## Documentation
|
|
47
|
+
|
|
48
|
+
For detailed documentation, please visit [https://climate-ref.readthedocs.io/](https://climate-ref.readthedocs.io/)
|
|
49
|
+
|
|
50
|
+
## Contributing
|
|
51
|
+
|
|
52
|
+
REF is a community project, and we welcome contributions from anyone. Please see our [Contributing Guide](https://climate-ref.readthedocs.io/en/latest/contributing/) for more information.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import importlib.resources
|
|
2
|
+
import shutil
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from urllib import parse as urlparse
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
import pytest
|
|
8
|
+
from climate_ref_example import provider as example_provider
|
|
9
|
+
from pytest_regressions.data_regression import RegressionYamlDumper
|
|
10
|
+
from yaml.representer import SafeRepresenter
|
|
11
|
+
|
|
12
|
+
from climate_ref.config import Config
|
|
13
|
+
from climate_ref.database import Database
|
|
14
|
+
from climate_ref.datasets.cmip6 import CMIP6DatasetAdapter
|
|
15
|
+
from climate_ref.datasets.obs4mips import Obs4MIPsDatasetAdapter
|
|
16
|
+
from climate_ref.models.metric_value import MetricValue
|
|
17
|
+
from climate_ref.provider_registry import _register_provider
|
|
18
|
+
from climate_ref_core.pycmec.controlled_vocabulary import CV
|
|
19
|
+
|
|
20
|
+
# Ignore the alembic folder
|
|
21
|
+
collect_ignore = ["src/climate_ref/migrations"]
|
|
22
|
+
|
|
23
|
+
# Add a representer for pandas Timestamps/NaT in the regression tests
|
|
24
|
+
RegressionYamlDumper.add_representer(
|
|
25
|
+
pd.Timestamp, lambda dumper, data: SafeRepresenter.represent_datetime(dumper, data.to_pydatetime())
|
|
26
|
+
)
|
|
27
|
+
RegressionYamlDumper.add_representer(
|
|
28
|
+
type(pd.NaT), lambda dumper, data: SafeRepresenter.represent_none(dumper, data)
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _clone_db(target_db_url: str, template_db_path: Path) -> None:
|
|
33
|
+
split_url = urlparse.urlsplit(target_db_url)
|
|
34
|
+
target_db_path = Path(split_url.path[1:])
|
|
35
|
+
target_db_path.parent.mkdir(parents=True)
|
|
36
|
+
|
|
37
|
+
shutil.copy(template_db_path, target_db_path)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def db(config) -> Database:
|
|
42
|
+
return Database.from_config(config, run_migrations=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@pytest.fixture(scope="session")
|
|
46
|
+
def cmip7_aft_cv() -> CV:
|
|
47
|
+
cv_file = str(importlib.resources.files("climate_ref_core.pycmec") / "cv_cmip7_aft.yaml")
|
|
48
|
+
|
|
49
|
+
return CV.load_from_file(cv_file)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.fixture(scope="session")
|
|
53
|
+
def prepare_db(cmip7_aft_cv):
|
|
54
|
+
MetricValue.register_cv_dimensions(cmip7_aft_cv)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@pytest.fixture(scope="session")
|
|
58
|
+
def db_seeded_template(tmp_path_session, cmip6_data_catalog, obs4mips_data_catalog, prepare_db) -> Path:
|
|
59
|
+
template_db_path = tmp_path_session / "climate_ref_template_seeded.db"
|
|
60
|
+
|
|
61
|
+
config = Config.default() # This is just dummy config
|
|
62
|
+
database = Database(f"sqlite:///{template_db_path}")
|
|
63
|
+
database.migrate(config)
|
|
64
|
+
|
|
65
|
+
# Seed the CMIP6 sample datasets
|
|
66
|
+
adapter = CMIP6DatasetAdapter()
|
|
67
|
+
with database.session.begin():
|
|
68
|
+
for instance_id, data_catalog_dataset in cmip6_data_catalog.groupby(adapter.slug_column):
|
|
69
|
+
adapter.register_dataset(config, database, data_catalog_dataset)
|
|
70
|
+
|
|
71
|
+
# Seed the obs4MIPs sample datasets
|
|
72
|
+
adapter_obs = Obs4MIPsDatasetAdapter()
|
|
73
|
+
with database.session.begin():
|
|
74
|
+
for instance_id, data_catalog_dataset in obs4mips_data_catalog.groupby(adapter_obs.slug_column):
|
|
75
|
+
adapter_obs.register_dataset(config, database, data_catalog_dataset)
|
|
76
|
+
|
|
77
|
+
with database.session.begin():
|
|
78
|
+
_register_provider(database, example_provider)
|
|
79
|
+
|
|
80
|
+
return template_db_path
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@pytest.fixture
|
|
84
|
+
def db_seeded(db_seeded_template, config) -> Database:
|
|
85
|
+
# Copy the template database to the location in the config
|
|
86
|
+
_clone_db(config.db.database_url, db_seeded_template)
|
|
87
|
+
|
|
88
|
+
return Database.from_config(config, run_migrations=True)
|