climate-ref-esmvaltool 0.8.0__py3-none-any.whl → 0.9.0__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.
@@ -2,14 +2,65 @@
2
2
  Rapid evaluating CMIP data with ESMValTool.
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
7
+ from pathlib import Path
8
+ from typing import TYPE_CHECKING
9
+
10
+ import pooch
11
+ from loguru import logger
12
+
5
13
  import climate_ref_esmvaltool.diagnostics
6
- from climate_ref_core.dataset_registry import DATASET_URL, dataset_registry_manager
14
+ from climate_ref_core.dataset_registry import (
15
+ DATASET_URL,
16
+ dataset_registry_manager,
17
+ fetch_all_files,
18
+ validate_registry_cache,
19
+ )
7
20
  from climate_ref_core.providers import CondaDiagnosticProvider
8
21
  from climate_ref_esmvaltool._version import __version__
9
22
  from climate_ref_esmvaltool.recipe import _ESMVALTOOL_COMMIT
10
23
 
24
+ if TYPE_CHECKING:
25
+ from climate_ref.config import Config
26
+
27
+ _REGISTRY_NAME = "esmvaltool"
28
+
29
+
30
+ class ESMValToolProvider(CondaDiagnosticProvider):
31
+ """Provider for ESMValTool diagnostics."""
32
+
33
+ def fetch_data(self, config: Config) -> None:
34
+ """Fetch ESMValTool reference data."""
35
+ registry = dataset_registry_manager[_REGISTRY_NAME]
36
+ fetch_all_files(registry, _REGISTRY_NAME, output_dir=None)
37
+
38
+ def validate_setup(self, config: Config) -> bool:
39
+ """Validate conda environment and data checksums."""
40
+ # First check conda environment
41
+ if not super().validate_setup(config):
42
+ return False
43
+
44
+ # Then check data checksums
45
+ registry = dataset_registry_manager[_REGISTRY_NAME]
46
+ errors = validate_registry_cache(registry, _REGISTRY_NAME)
47
+ if errors:
48
+ for error in errors:
49
+ logger.error(f"{self.slug} validation failed: {error}")
50
+ logger.error(
51
+ f"Data for {self.slug} is missing or corrupted. "
52
+ f"Please run `ref providers setup --provider {self.slug}` to fetch data."
53
+ )
54
+ return False
55
+ return True
56
+
57
+ def get_data_path(self) -> Path | None:
58
+ """Get the path where ESMValTool data is cached."""
59
+ return Path(pooch.os_cache("climate_ref"))
60
+
61
+
11
62
  # Initialise the diagnostics manager.
12
- provider = CondaDiagnosticProvider(
63
+ provider = ESMValToolProvider(
13
64
  "ESMValTool",
14
65
  __version__,
15
66
  repo="https://github.com/ESMValGroup/ESMValTool.git",
@@ -144,8 +144,9 @@ def dataframe_to_recipe(
144
144
  return variables
145
145
 
146
146
 
147
- _ESMVALTOOL_COMMIT = "2c438d0e0cc8904790294c72450eb7f06552c52a"
148
- _ESMVALTOOL_VERSION = f"2.13.0.dev148+g{_ESMVALTOOL_COMMIT[:9]}"
147
+ _ESMVALTOOL_COMMIT = "fa3e10ed09fc34d354f179a6a71aacd032d6ea9e"
148
+ # _ESMVALTOOL_VERSION = f"2.13.0.dev148+g{_ESMVALTOOL_COMMIT[:9]}"
149
+ _ESMVALTOOL_VERSION = "2.13.0"
149
150
 
150
151
  _RECIPES = pooch.create(
151
152
  path=pooch.os_cache("climate_ref_esmvaltool"),