climate-ref-core 0.6.1__tar.gz → 0.6.3__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.
Files changed (46) hide show
  1. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/PKG-INFO +2 -2
  2. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/pyproject.toml +2 -2
  3. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/dataset_registry.py +1 -1
  4. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/exceptions.py +6 -0
  5. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/providers.py +7 -1
  6. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/controlled_vocabulary.py +2 -5
  7. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_providers.py +26 -16
  8. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/.gitignore +0 -0
  9. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/LICENCE +0 -0
  10. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/NOTICE +0 -0
  11. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/README.md +0 -0
  12. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/__init__.py +0 -0
  13. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/constraints.py +0 -0
  14. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/datasets.py +0 -0
  15. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/diagnostics.py +0 -0
  16. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/env.py +0 -0
  17. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/executor.py +0 -0
  18. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/logging.py +0 -0
  19. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/metric_values/__init__.py +0 -0
  20. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/metric_values/typing.py +0 -0
  21. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/py.typed +0 -0
  22. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/README.md +0 -0
  23. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/__init__.py +0 -0
  24. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/cv_cmip7_aft.yaml +0 -0
  25. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/metric.py +0 -0
  26. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/src/climate_ref_core/pycmec/output.py +0 -0
  27. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/metric_values/test_typing.py +0 -0
  28. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/cmec_testdata/cmec_metric_sample.json +0 -0
  29. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/cmec_testdata/cmec_output_sample.json +0 -0
  30. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/cmec_testdata/cv_sample.yaml +0 -0
  31. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/cmec_testdata/test_metric_json_schema.yml +0 -0
  32. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/cmec_testdata/test_output_json_schema.yml +0 -0
  33. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/conftest.py +0 -0
  34. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/test_cmec_metric.py +0 -0
  35. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/test_cmec_output.py +0 -0
  36. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/pycmec/test_controlled_vocabulary.py +0 -0
  37. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_constraints.py +0 -0
  38. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_dataset_registry/test_dataset_registry.py +0 -0
  39. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_datasets/dataset_collection_hash.yml +0 -0
  40. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_datasets/dataset_collection_obs4mips_hash.yml +0 -0
  41. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_datasets/metric_dataset_hash.yml +0 -0
  42. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_datasets.py +0 -0
  43. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_exceptions.py +0 -0
  44. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_executor.py +0 -0
  45. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_logging.py +0 -0
  46. {climate_ref_core-0.6.1 → climate_ref_core-0.6.3}/tests/unit/test_metrics.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: climate-ref-core
3
- Version: 0.6.1
3
+ Version: 0.6.3
4
4
  Summary: Core library for the CMIP Rapid Evaluation Framework
5
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
6
  License-Expression: Apache-2.0
@@ -26,9 +26,9 @@ Requires-Dist: numpy>=1.25.0
26
26
  Requires-Dist: pandas>=2.1.0
27
27
  Requires-Dist: pooch<2,>=1.8.0
28
28
  Requires-Dist: pydantic>=2.10.6
29
+ Requires-Dist: pyyaml>=6.0.2
29
30
  Requires-Dist: requests
30
31
  Requires-Dist: rich
31
- Requires-Dist: ruamel-yaml>=0.18
32
32
  Requires-Dist: setuptools>=75.8.0
33
33
  Requires-Dist: typing-extensions
34
34
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "climate-ref-core"
3
- version = "0.6.1"
3
+ version = "0.6.3"
4
4
  description = "Core library for the CMIP Rapid Evaluation Framework"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -36,8 +36,8 @@ dependencies = [
36
36
  "rich",
37
37
  "loguru>=0.7.0",
38
38
  "pooch>=1.8.0,<2",
39
- "ruamel.yaml>=0.18",
40
39
  "environs>=11",
40
+ "pyyaml>=6.0.2",
41
41
  # Not used directly, but required to support some installations
42
42
  "setuptools>=75.8.0",
43
43
 
@@ -18,7 +18,7 @@ from rich.progress import track
18
18
 
19
19
  from climate_ref_core.env import env
20
20
 
21
- DATASET_URL = env.str("REF_DATASET_URL", default="https://pub-b093171261094c4ea9adffa01f94ee06.r2.dev")
21
+ DATASET_URL = env.str("REF_DATASET_URL", default="https://obs4ref.climate-ref.org")
22
22
 
23
23
 
24
24
  def _verify_hash_matches(fname: str | pathlib.Path, known_hash: str) -> bool:
@@ -60,4 +60,10 @@ class DiagnosticError(RefException):
60
60
 
61
61
  def __init__(self, message: str, result: Any):
62
62
  super().__init__(message)
63
+ self.message = message
63
64
  self.result = result
65
+
66
+ # need for serialization of parsl
67
+ def __reduce__(self) -> tuple[type["DiagnosticError"], tuple[str, Any]]:
68
+ # Return a tuple: (callable, args_tuple_for_reconstruction)
69
+ return (self.__class__, (self.message, self.result))
@@ -390,7 +390,13 @@ class CondaDiagnosticProvider(CommandLineDiagnosticProvider):
390
390
  If the command fails
391
391
 
392
392
  """
393
- self.create_env()
393
+ if not self.env_path.exists():
394
+ msg = (
395
+ f"Conda environment for provider `{self.slug}` not available at "
396
+ f"{self.env_path}. Please install it by running the command "
397
+ f"`ref providers create-env --provider {self.slug}`"
398
+ )
399
+ raise RuntimeError(msg)
394
400
 
395
401
  cmd = [
396
402
  f"{self.get_conda_exe(update=False)}",
@@ -4,14 +4,11 @@ from typing import Any
4
4
  from attrs import field, frozen, validators
5
5
  from cattrs import Converter, transform_error
6
6
  from loguru import logger
7
- from ruamel.yaml import YAML
7
+ from yaml import safe_load
8
8
 
9
9
  from climate_ref_core.exceptions import ResultValidationError
10
10
  from climate_ref_core.pycmec.metric import CMECMetric
11
11
 
12
- yaml = YAML()
13
-
14
-
15
12
  RESERVED_DIMENSION_NAMES = {"attributes", "json_structure", "created_at", "updated_at", "value", "id"}
16
13
  """
17
14
  These names are reserved for internal use and should not be used as dimension names.
@@ -164,9 +161,9 @@ class CV:
164
161
 
165
162
  """
166
163
  convertor = Converter(forbid_extra_keys=True)
167
- contents = yaml.load(pathlib.Path(filename))
168
164
 
169
165
  try:
166
+ contents = safe_load(pathlib.Path(filename).read_text(encoding="utf-8"))
170
167
  return convertor.structure(contents, CV)
171
168
  except Exception as exc:
172
169
  logger.error(f"Error loading CV from {filename}")
@@ -256,9 +256,12 @@ class TestCondaMetricsProvider:
256
256
 
257
257
  assert f"Environment at {env_path} already exists, skipping." in caplog.text
258
258
 
259
- def test_run(self, mocker, tmp_path, provider):
259
+ @pytest.mark.parametrize("env_exists", [True, False])
260
+ def test_run(self, mocker, tmp_path, provider, env_exists):
260
261
  conda_exe = tmp_path / "conda" / "micromamba"
261
262
  env_path = provider.prefix / "mock-env"
263
+ if env_exists:
264
+ env_path.mkdir(parents=True)
262
265
 
263
266
  mocker.patch.object(
264
267
  CondaDiagnosticProvider,
@@ -284,18 +287,25 @@ class TestCondaMetricsProvider:
284
287
  create_autospec=True,
285
288
  )
286
289
 
287
- provider.run(["mock-command"])
288
-
289
- run.assert_called_with(
290
- [
291
- f"{conda_exe}",
292
- "run",
293
- "--prefix",
294
- f"{env_path}",
295
- "mock-command",
296
- ],
297
- check=True,
298
- stdout=subprocess.PIPE,
299
- stderr=subprocess.STDOUT,
300
- text=True,
301
- )
290
+ if not env_exists:
291
+ with pytest.raises(
292
+ RuntimeError,
293
+ match=(f"Conda environment for provider `{provider.slug}` not available at {env_path}."),
294
+ ):
295
+ provider.run(["mock-command"])
296
+ else:
297
+ provider.run(["mock-command"])
298
+
299
+ run.assert_called_with(
300
+ [
301
+ f"{conda_exe}",
302
+ "run",
303
+ "--prefix",
304
+ f"{env_path}",
305
+ "mock-command",
306
+ ],
307
+ check=True,
308
+ stdout=subprocess.PIPE,
309
+ stderr=subprocess.STDOUT,
310
+ text=True,
311
+ )