climate-ref-core 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

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.
@@ -53,3 +53,17 @@ class ExecutionError(RefException):
53
53
 
54
54
  def __init__(self, message: str) -> None:
55
55
  super().__init__(message)
56
+
57
+
58
+ class DiagnosticError(RefException):
59
+ """Error from diagnostic computing"""
60
+
61
+ def __init__(self, message: str, result: Any):
62
+ super().__init__(message)
63
+ self.message = message
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))
@@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
9
9
  from loguru import logger
10
10
 
11
11
  from climate_ref_core.diagnostics import ExecutionDefinition, ExecutionResult
12
- from climate_ref_core.exceptions import InvalidExecutorException
12
+ from climate_ref_core.exceptions import DiagnosticError, InvalidExecutorException
13
13
  from climate_ref_core.logging import redirect_logs
14
14
 
15
15
  if TYPE_CHECKING:
@@ -20,6 +20,7 @@ if TYPE_CHECKING:
20
20
  def execute_locally(
21
21
  definition: ExecutionDefinition,
22
22
  log_level: str,
23
+ raise_error: bool = False,
23
24
  ) -> ExecutionResult:
24
25
  """
25
26
  Run a diagnostic execution
@@ -46,10 +47,15 @@ def execute_locally(
46
47
 
47
48
  with redirect_logs(definition, log_level):
48
49
  return definition.diagnostic.run(definition=definition)
49
- except Exception:
50
+ except Exception as e:
50
51
  # If the diagnostic fails, we want to log the error and return a failure result
51
52
  logger.exception(f"Error running {definition.execution_slug()!r}")
52
- return ExecutionResult.build_from_failure(definition)
53
+ result = ExecutionResult.build_from_failure(definition)
54
+
55
+ if raise_error:
56
+ raise DiagnosticError(str(e), result) from e
57
+ else:
58
+ return result
53
59
 
54
60
 
55
61
  @runtime_checkable
@@ -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}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: climate-ref-core
3
- Version: 0.6.0
3
+ Version: 0.6.2
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
@@ -4,21 +4,21 @@ climate_ref_core/dataset_registry.py,sha256=mkes7Pgz_zaS_t_BidiDzSd8dmqAvjx2Mlgo
4
4
  climate_ref_core/datasets.py,sha256=TK50WQwTfbase26s8wPEGEN1BwcedrOd8nk6IlEf3Ww,6124
5
5
  climate_ref_core/diagnostics.py,sha256=5KCtHuhToSpATqjW4HBi56PsOxT5WX4VkqoZPUvYR60,18769
6
6
  climate_ref_core/env.py,sha256=Ph2dejVxTELfP3bL0xES086WLGvV5H6KvsOwCkL6m-k,753
7
- climate_ref_core/exceptions.py,sha256=psdipWURLyMq5hmloGxt-8kyqEe0IsENfraok7KTi8I,1437
8
- climate_ref_core/executor.py,sha256=NIXIU2rwMnTOR-ztlPlCD-poZO4vxzKQPWYk8veTVkk,5195
7
+ climate_ref_core/exceptions.py,sha256=7Mkz22P-kbiL-ZevAhlOuQaaeTio6zpwE9YA45OTGvs,1909
8
+ climate_ref_core/executor.py,sha256=QiVOca-d9JxKIktQIinQQYZGr3ecV5mL3nvUwCdMiJQ,5372
9
9
  climate_ref_core/logging.py,sha256=cg6CK2DHGjyLaoRJm75p-Ja82hnVhBBQ4riOKk3l9XY,7063
10
- climate_ref_core/providers.py,sha256=by_ZtoLQgg9A60CbFor2-i5EixtZTZ0z8jQqOGRfvA8,12461
10
+ climate_ref_core/providers.py,sha256=Gq2RWBp_GJZG8tUMoRMVL-UJ_ugTYtvWHEqwMK9JHt8,12773
11
11
  climate_ref_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  climate_ref_core/metric_values/__init__.py,sha256=aHfwRrqzLOmmaBKf1-4q97DnHb8KwmW0Dhwd79ZQiNQ,634
13
13
  climate_ref_core/metric_values/typing.py,sha256=2DpzmjqQ7tqOPAyjthZ_O14c0-MhiYt-A_n9p6-bOao,1903
14
14
  climate_ref_core/pycmec/README.md,sha256=PzkovlPpsXqFopsYzz5GRvCAipNRGO1Wo-0gc17qr2Y,36
15
15
  climate_ref_core/pycmec/__init__.py,sha256=hXvKGEJQWyAp1i-ndr3D4zuYxkRhcR2LfXgFXlhYOk4,28
16
- climate_ref_core/pycmec/controlled_vocabulary.py,sha256=ThdTBsSmUemyXSQG5RycN31qp93LfqIyPqvI8x5cdLI,5114
16
+ climate_ref_core/pycmec/controlled_vocabulary.py,sha256=_GZ2Y6KAYF12I3IS27g8YdFBAcAONyGAhpucQ4oEcOA,5128
17
17
  climate_ref_core/pycmec/cv_cmip7_aft.yaml,sha256=gx5QyW88pZQVUfiYXmsJtJO6AJg6NbIZgdU4vDIa3fE,4390
18
18
  climate_ref_core/pycmec/metric.py,sha256=zymXoutnjbdcxvG_fMJugFLLcBrfSPG0XoV-2tA0ujA,18499
19
19
  climate_ref_core/pycmec/output.py,sha256=4-RQ439sfgNLeQZVDPB1pewF_kTwX7nCK0Z4U6bvbd0,5709
20
- climate_ref_core-0.6.0.dist-info/METADATA,sha256=pVHPIwK0q0j1KyG7ui9FeMa2wFLpoC8zWrBKJ58WG5c,2934
21
- climate_ref_core-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
- climate_ref_core-0.6.0.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
- climate_ref_core-0.6.0.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
24
- climate_ref_core-0.6.0.dist-info/RECORD,,
20
+ climate_ref_core-0.6.2.dist-info/METADATA,sha256=TgifPLfIx9XtegPkLFv-aJ1MZuCr6xbMySuMuIaXYBU,2930
21
+ climate_ref_core-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ climate_ref_core-0.6.2.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
+ climate_ref_core-0.6.2.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
24
+ climate_ref_core-0.6.2.dist-info/RECORD,,