esgvoc 0.1.2__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.

Potentially problematic release.


This version of esgvoc might be problematic. Click here for more details.

Files changed (73) hide show
  1. esgvoc-0.1.2/.github/workflows/pypi-publish.yml +33 -0
  2. esgvoc-0.1.2/.gitignore +21 -0
  3. esgvoc-0.1.2/PKG-INFO +54 -0
  4. esgvoc-0.1.2/README.md +37 -0
  5. esgvoc-0.1.2/pyproject.toml +58 -0
  6. esgvoc-0.1.2/src/esgvoc/__init__.py +1 -0
  7. esgvoc-0.1.2/src/esgvoc/api/__init__.py +62 -0
  8. esgvoc-0.1.2/src/esgvoc/api/_utils.py +39 -0
  9. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/__init__.py +60 -0
  10. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/activity.py +51 -0
  11. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/consortium.py +66 -0
  12. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/date.py +48 -0
  13. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/experiment.py +60 -0
  14. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/forcing_index.py +47 -0
  15. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/frequency.py +45 -0
  16. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/grid_label.py +46 -0
  17. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/initialisation_index.py +46 -0
  18. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/institution.py +58 -0
  19. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/license.py +47 -0
  20. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/mip_era.py +46 -0
  21. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/model_component.py +47 -0
  22. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/organisation.py +42 -0
  23. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/physic_index.py +47 -0
  24. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/product.py +45 -0
  25. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/realisation_index.py +46 -0
  26. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/realm.py +44 -0
  27. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/resolution.py +46 -0
  28. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/source.py +57 -0
  29. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/source_type.py +43 -0
  30. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/sub_experiment.py +43 -0
  31. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/table.py +50 -0
  32. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/time_range.py +28 -0
  33. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/variable.py +77 -0
  34. esgvoc-0.1.2/src/esgvoc/api/data_descriptors/variant_label.py +49 -0
  35. esgvoc-0.1.2/src/esgvoc/api/projects.py +854 -0
  36. esgvoc-0.1.2/src/esgvoc/api/report.py +86 -0
  37. esgvoc-0.1.2/src/esgvoc/api/search.py +92 -0
  38. esgvoc-0.1.2/src/esgvoc/api/universe.py +218 -0
  39. esgvoc-0.1.2/src/esgvoc/apps/drs/__init__.py +16 -0
  40. esgvoc-0.1.2/src/esgvoc/apps/drs/models.py +43 -0
  41. esgvoc-0.1.2/src/esgvoc/apps/drs/parser.py +27 -0
  42. esgvoc-0.1.2/src/esgvoc/cli/config.py +79 -0
  43. esgvoc-0.1.2/src/esgvoc/cli/get.py +142 -0
  44. esgvoc-0.1.2/src/esgvoc/cli/install.py +14 -0
  45. esgvoc-0.1.2/src/esgvoc/cli/main.py +22 -0
  46. esgvoc-0.1.2/src/esgvoc/cli/status.py +26 -0
  47. esgvoc-0.1.2/src/esgvoc/cli/valid.py +156 -0
  48. esgvoc-0.1.2/src/esgvoc/core/constants.py +13 -0
  49. esgvoc-0.1.2/src/esgvoc/core/convert.py +0 -0
  50. esgvoc-0.1.2/src/esgvoc/core/data_handler.py +133 -0
  51. esgvoc-0.1.2/src/esgvoc/core/db/__init__.py +5 -0
  52. esgvoc-0.1.2/src/esgvoc/core/db/connection.py +31 -0
  53. esgvoc-0.1.2/src/esgvoc/core/db/models/mixins.py +18 -0
  54. esgvoc-0.1.2/src/esgvoc/core/db/models/project.py +65 -0
  55. esgvoc-0.1.2/src/esgvoc/core/db/models/universe.py +59 -0
  56. esgvoc-0.1.2/src/esgvoc/core/db/project_ingestion.py +152 -0
  57. esgvoc-0.1.2/src/esgvoc/core/db/universe_ingestion.py +120 -0
  58. esgvoc-0.1.2/src/esgvoc/core/logging.conf +21 -0
  59. esgvoc-0.1.2/src/esgvoc/core/logging_handler.py +4 -0
  60. esgvoc-0.1.2/src/esgvoc/core/repo_fetcher.py +259 -0
  61. esgvoc-0.1.2/src/esgvoc/core/service/__init__.py +8 -0
  62. esgvoc-0.1.2/src/esgvoc/core/service/data_merger.py +83 -0
  63. esgvoc-0.1.2/src/esgvoc/core/service/esg_voc.py +79 -0
  64. esgvoc-0.1.2/src/esgvoc/core/service/settings.py +64 -0
  65. esgvoc-0.1.2/src/esgvoc/core/service/settings.toml +12 -0
  66. esgvoc-0.1.2/src/esgvoc/core/service/settings_default.toml +20 -0
  67. esgvoc-0.1.2/src/esgvoc/core/service/state.py +222 -0
  68. esgvoc-0.1.2/tests/test_api_project.py +178 -0
  69. esgvoc-0.1.2/tests/test_api_universe.py +68 -0
  70. esgvoc-0.1.2/tests/test_data_handler.py +55 -0
  71. esgvoc-0.1.2/tests/test_data_merger.py +133 -0
  72. esgvoc-0.1.2/tests/test_repo_fetcher.py +143 -0
  73. esgvoc-0.1.2/tests/test_state.py +105 -0
@@ -0,0 +1,33 @@
1
+
2
+ name: pypi-publish
3
+
4
+ on:
5
+ release:
6
+ types:
7
+ - published
8
+
9
+ jobs:
10
+ pypi-publish:
11
+ name: upload release to PyPI
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ # This permission is needed for private repositories.
15
+ contents: read
16
+ # IMPORTANT: this permission is mandatory for trusted publishing
17
+ id-token: write
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+
21
+ - name: Install the latest version of rye
22
+ uses: eifinger/setup-rye@v4
23
+ with:
24
+ enable-cache: true
25
+
26
+ - name: Sync dependencies
27
+ run: rye sync
28
+
29
+ - name: Build package
30
+ run: rye build
31
+
32
+ - name: Publish package distributions to PyPI
33
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,21 @@
1
+ # python generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+ mip-cmor-tables/
9
+ sb.py
10
+ # venv
11
+ .venv
12
+ *.lock
13
+ *.sqlite
14
+ .pdm-python
15
+ .DS_Store
16
+ .vscode
17
+ tmp*
18
+ .cache
19
+ CHANGELOG.md
20
+ .mise.toml
21
+ .mise.toml
esgvoc-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.3
2
+ Name: esgvoc
3
+ Version: 0.1.2
4
+ Summary: python library and CLI to interact with WCRP CV
5
+ Project-URL: Repository, https://github.com/ESPRI-Mod/cmipld
6
+ Author-email: TROUSSELLIER Laurent <laurent.troussellier@ipsl.fr>, Gardoll Sébastien <sebastien@gardoll.fr>
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: idna>=3.10
9
+ Requires-Dist: pydantic>=2.9.2
10
+ Requires-Dist: pyld>=2.0.4
11
+ Requires-Dist: requests>=2.32.3
12
+ Requires-Dist: sqlalchemy>=2.0.36
13
+ Requires-Dist: sqlmodel>=0.0.22
14
+ Requires-Dist: toml>=0.10.2
15
+ Requires-Dist: typer>=0.15.0
16
+ Description-Content-Type: text/markdown
17
+
18
+
19
+ # Esgvoc Library
20
+
21
+ Esgvoc is a Python library designed to simplify interaction with controlled vocabularies (CVs) used in climate data projects. It supports querying, caching, and validating terms across various CV repositories like the Universe and project-specific repositories (e.g., CMIP6Plus).
22
+
23
+ ---
24
+
25
+ ## Features
26
+
27
+ - **Query controlled vocabularies**:
28
+ - Retrieve terms, collections, or descriptors.
29
+ - Perform cross-validation and search operations.
30
+
31
+ - **Caching**:
32
+ - Download CVs to a local database for offline use.
33
+ - Keep the local cache up-to-date.
34
+
35
+ - **Validation**:
36
+ - Validate strings against CV terms and templates.
37
+ - Supports case-sensitive, wildcard, and approximate matching.
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ Esgvoc is available on PyPI. Install it with pip:
44
+
45
+ ```bash
46
+ pip install esgvoc
47
+ ```
48
+
49
+ in order to get the latest possible CV
50
+
51
+
52
+ ```bash
53
+ esgvoc install
54
+ ```
esgvoc-0.1.2/README.md ADDED
@@ -0,0 +1,37 @@
1
+
2
+ # Esgvoc Library
3
+
4
+ Esgvoc is a Python library designed to simplify interaction with controlled vocabularies (CVs) used in climate data projects. It supports querying, caching, and validating terms across various CV repositories like the Universe and project-specific repositories (e.g., CMIP6Plus).
5
+
6
+ ---
7
+
8
+ ## Features
9
+
10
+ - **Query controlled vocabularies**:
11
+ - Retrieve terms, collections, or descriptors.
12
+ - Perform cross-validation and search operations.
13
+
14
+ - **Caching**:
15
+ - Download CVs to a local database for offline use.
16
+ - Keep the local cache up-to-date.
17
+
18
+ - **Validation**:
19
+ - Validate strings against CV terms and templates.
20
+ - Supports case-sensitive, wildcard, and approximate matching.
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ Esgvoc is available on PyPI. Install it with pip:
27
+
28
+ ```bash
29
+ pip install esgvoc
30
+ ```
31
+
32
+ in order to get the latest possible CV
33
+
34
+
35
+ ```bash
36
+ esgvoc install
37
+ ```
@@ -0,0 +1,58 @@
1
+ [project]
2
+ name = "esgvoc"
3
+ version = "0.1.2"
4
+ description = "python library and CLI to interact with WCRP CV"
5
+ authors = [
6
+ {name = "TROUSSELLIER Laurent", email = "laurent.troussellier@ipsl.fr"},
7
+ {name = "Gardoll Sébastien", email = "sebastien@gardoll.fr"}
8
+ ]
9
+ dependencies = [
10
+ "idna>=3.10",
11
+ "pydantic>=2.9.2",
12
+ "sqlalchemy>=2.0.36",
13
+ "sqlmodel>=0.0.22",
14
+ "pyld>=2.0.4",
15
+ "requests>=2.32.3",
16
+ "toml>=0.10.2",
17
+ "typer>=0.15.0",
18
+ ]
19
+ readme = "README.md"
20
+ requires-python = ">= 3.12"
21
+
22
+ [build-system]
23
+ requires = ["hatchling==1.26.3"]
24
+ build-backend = "hatchling.build"
25
+
26
+ [project.urls]
27
+ Repository = "https://github.com/ESPRI-Mod/cmipld"
28
+
29
+ [tool.rye]
30
+ managed = true
31
+ dev-dependencies = [
32
+ "pytest>=8.3.3",
33
+ "jupyter-console>=6.6.3",
34
+ "mypy>=1.13.0",
35
+ "pytest-mock>=3.14.0",
36
+ "isort>=5.13.2",
37
+ ]
38
+ [tool.rye.scripts]
39
+ ev = { cmd = "python src/esgvoc/cli/main.py" }
40
+ evc = { cmd = "python src/esgvoc/cli/main.py config" }
41
+ evcp = { cmd = "python src/esgvoc/cli/main.py config projects." }
42
+ evg = { cmd = "python src/esgvoc/cli/main.py get" }
43
+ evs = {cmd = "python src/esgvoc/cli/main.py status"}
44
+ evv = {cmd = "python src/esgvoc/cli/main.py valid"}
45
+
46
+ [project.scripts]
47
+ esgvoc = "esgvoc.cli.main:main"
48
+
49
+ [tool.hatch.metadata]
50
+ allow-direct-references = true
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["src/esgvoc"]
54
+
55
+ [tool.pytest.ini_options]
56
+ log_cli = true
57
+ log_cli_level = "ERROR"
58
+ log_cli_format = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
@@ -0,0 +1 @@
1
+ import esgvoc.core.logging_handler
@@ -0,0 +1,62 @@
1
+ from esgvoc.api.search import MatchingTerm, SearchType, SearchSettings
2
+ from esgvoc.api.report import (ValidationError,
3
+ ValidationReport,
4
+ ValidationErrorVisitor,
5
+ BasicValidationErrorVisitor,
6
+ ProjectTermError,
7
+ UniverseTermError)
8
+ from esgvoc.api.universe import (get_all_terms_in_universe,
9
+ get_all_data_descriptors_in_universe,
10
+ find_data_descriptors_in_universe,
11
+ get_all_terms_in_data_descriptor,
12
+ find_terms_in_universe,
13
+ find_terms_in_data_descriptor)
14
+ from esgvoc.api.projects import (get_all_projects,
15
+ find_project,
16
+ get_all_terms_in_all_projects,
17
+ get_all_terms_in_project,
18
+ get_all_collections_in_project,
19
+ find_collections_in_project,
20
+ get_all_terms_in_collection,
21
+ find_terms_in_project,
22
+ find_terms_in_all_projects,
23
+ find_terms_from_data_descriptor_in_all_projects,
24
+ find_terms_from_data_descriptor_in_project,
25
+ find_terms_in_collection,
26
+ valid_term_in_all_projects,
27
+ valid_term_in_project,
28
+ valid_term_in_collection,
29
+ valid_term)
30
+
31
+
32
+ __all__ = ["MatchingTerm",
33
+ "SearchType",
34
+ "SearchSettings",
35
+ "ValidationError",
36
+ "ValidationReport",
37
+ "ValidationErrorVisitor",
38
+ "BasicValidationErrorVisitor",
39
+ "ProjectTermError",
40
+ "UniverseTermError",
41
+ "get_all_terms_in_universe",
42
+ "get_all_data_descriptors_in_universe",
43
+ "find_data_descriptors_in_universe",
44
+ "get_all_terms_in_data_descriptor",
45
+ "find_terms_in_universe",
46
+ "find_terms_in_data_descriptor",
47
+ "get_all_projects",
48
+ "find_project",
49
+ "get_all_terms_in_all_projects",
50
+ "get_all_terms_in_project",
51
+ "get_all_collections_in_project",
52
+ "find_collections_in_project",
53
+ "get_all_terms_in_collection",
54
+ "find_terms_in_project",
55
+ "find_terms_in_all_projects",
56
+ "find_terms_from_data_descriptor_in_all_projects",
57
+ "find_terms_from_data_descriptor_in_project",
58
+ "find_terms_in_collection",
59
+ "valid_term_in_all_projects",
60
+ "valid_term_in_project",
61
+ "valid_term_in_collection",
62
+ "valid_term"]
@@ -0,0 +1,39 @@
1
+ from typing import Sequence
2
+
3
+
4
+ import esgvoc.core.constants as api_settings
5
+ from esgvoc.api.data_descriptors import DATA_DESCRIPTOR_CLASS_MAPPING
6
+ from esgvoc.core.db.models.project import PTerm
7
+ from esgvoc.core.db.models.universe import UTerm
8
+ from pydantic import BaseModel
9
+ from sqlmodel import Session
10
+
11
+ import esgvoc.core.service as service
12
+ UNIVERSE_DB_CONNECTION = service.state_service.universe.db_connection
13
+
14
+
15
+ def get_pydantic_class(data_descriptor_id_or_term_type: str) -> type[BaseModel]:
16
+ if data_descriptor_id_or_term_type in DATA_DESCRIPTOR_CLASS_MAPPING:
17
+ return DATA_DESCRIPTOR_CLASS_MAPPING[data_descriptor_id_or_term_type]
18
+ else:
19
+ raise ValueError(f"{data_descriptor_id_or_term_type} pydantic class not found")
20
+
21
+
22
+ def get_universe_session() -> Session:
23
+
24
+ if UNIVERSE_DB_CONNECTION:
25
+ return UNIVERSE_DB_CONNECTION.create_session()
26
+ else:
27
+ raise RuntimeError('universe connection is not initialized')
28
+
29
+
30
+ def instantiate_pydantic_term(term: UTerm|PTerm) -> BaseModel:
31
+ term_class = get_pydantic_class(term.specs[api_settings.TERM_TYPE_JSON_KEY])
32
+ return term_class(**term.specs)
33
+
34
+
35
+ def instantiate_pydantic_terms(db_terms: Sequence[UTerm|PTerm],
36
+ list_to_populate: list[BaseModel]) -> None:
37
+ for db_term in db_terms:
38
+ term = instantiate_pydantic_term(db_term)
39
+ list_to_populate.append(term)
@@ -0,0 +1,60 @@
1
+ from pydantic import BaseModel
2
+
3
+ from esgvoc.api.data_descriptors.activity import Activity
4
+ from esgvoc.api.data_descriptors.consortium import Consortium
5
+ from esgvoc.api.data_descriptors.date import Date
6
+ from esgvoc.api.data_descriptors.experiment import Experiment
7
+ from esgvoc.api.data_descriptors.forcing_index import ForcingIndex
8
+ from esgvoc.api.data_descriptors.frequency import Frequency
9
+ from esgvoc.api.data_descriptors.grid_label import GridLabel
10
+ from esgvoc.api.data_descriptors.initialisation_index import InitialisationIndex
11
+ from esgvoc.api.data_descriptors.institution import Institution
12
+ from esgvoc.api.data_descriptors.license import License
13
+ from esgvoc.api.data_descriptors.mip_era import MipEra
14
+ from esgvoc.api.data_descriptors.model_component import ModelComponent
15
+ from esgvoc.api.data_descriptors.organisation import Organisation
16
+ from esgvoc.api.data_descriptors.physic_index import PhysicIndex
17
+ from esgvoc.api.data_descriptors.product import Product
18
+ from esgvoc.api.data_descriptors.realisation_index import RealisationIndex
19
+ from esgvoc.api.data_descriptors.realm import Realm
20
+ from esgvoc.api.data_descriptors.resolution import Resolution
21
+ from esgvoc.api.data_descriptors.source import Source
22
+ from esgvoc.api.data_descriptors.source_type import SourceType
23
+ from esgvoc.api.data_descriptors.sub_experiment import SubExperiment
24
+ from esgvoc.api.data_descriptors.table import Table
25
+ from esgvoc.api.data_descriptors.time_range import TimeRange
26
+ from esgvoc.api.data_descriptors.variable import Variable
27
+ from esgvoc.api.data_descriptors.variant_label import VariantLabel
28
+
29
+
30
+ DATA_DESCRIPTOR_CLASS_MAPPING: dict[str, type[BaseModel]] = {
31
+ "activity": Activity,
32
+ "consortium": Consortium,
33
+ "date": Date,
34
+ "experiment": Experiment,
35
+ "forcing_index": ForcingIndex,
36
+ "frequency": Frequency,
37
+ "grid": GridLabel, # DEBUG: the value of the key type for the terms of the DD grid is not consistent.
38
+ "grid-label": GridLabel, # DEBUG: the value of the key type for the terms of the DD grid is not consistent.
39
+ "grid_label": GridLabel, # DEBUG: the value of the key type for the terms of the DD grid is not consistent.
40
+ "initialisation_index": InitialisationIndex,
41
+ "institution": Institution,
42
+ "license": License,
43
+ "mip_era": MipEra,
44
+ "model_component": ModelComponent,
45
+ "organisation": Organisation,
46
+ "physic_index": PhysicIndex,
47
+ "product": Product,
48
+ "realisation_index": RealisationIndex ,
49
+ "realm": Realm,
50
+ "resolution": Resolution,
51
+ "source": Source,
52
+ "source_type": SourceType,
53
+ "sub_experiment": SubExperiment,
54
+ "table" : Table,
55
+ "time_range": TimeRange,
56
+ "variable": Variable,
57
+ "real": Variable, # DEBUG: key type should be the pydantic class for the terms of DD variable!
58
+ "integer": Variable, # DEBUG: key type should be the pydantic class for the terms of DD variable!
59
+ "variant_label": VariantLabel
60
+ }
@@ -0,0 +1,51 @@
1
+
2
+ from __future__ import annotations
3
+ from typing import (
4
+ Optional
5
+ )
6
+ from pydantic.version import VERSION as PYDANTIC_VERSION
7
+ if int(PYDANTIC_VERSION[0])>=2:
8
+ from pydantic import (
9
+ BaseModel,
10
+ ConfigDict,
11
+ Field
12
+ )
13
+ else:
14
+ from pydantic import (
15
+ BaseModel,
16
+ Field
17
+ )
18
+
19
+ metamodel_version = "None"
20
+ version = "None"
21
+
22
+
23
+ class ConfiguredBaseModel(BaseModel):
24
+ model_config = ConfigDict(
25
+ validate_assignment = True,
26
+ validate_default = True,
27
+ extra = "allow",
28
+ arbitrary_types_allowed = True,
29
+ use_enum_values = True,
30
+ strict = False,
31
+ )
32
+ pass
33
+
34
+
35
+
36
+ class Activity(ConfiguredBaseModel):
37
+ """
38
+ an 'activity' refers to a coordinated set of modeling experiments designed to address specific scientific questions or objectives. Each activity is focused on different aspects of climate science and utilizes various models to study a wide range of climate phenomena. Activities are often organized around key research themes and may involve multiple experiments, scenarios, and model configurations.
39
+ """
40
+
41
+ id: str
42
+ validation_method: str = Field(default = "list")
43
+ name: str
44
+ long_name: str
45
+ cmip_acronym: str
46
+ url: Optional[str]
47
+
48
+
49
+ # Model rebuild
50
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
51
+ Activity.model_rebuild()
@@ -0,0 +1,66 @@
1
+
2
+ from __future__ import annotations
3
+ from typing import (
4
+ List,
5
+ Optional,
6
+ Union
7
+ )
8
+ from pydantic.version import VERSION as PYDANTIC_VERSION
9
+ if int(PYDANTIC_VERSION[0])>=2:
10
+ from pydantic import (
11
+ BaseModel,
12
+ ConfigDict,
13
+ Field
14
+ )
15
+ else:
16
+ from pydantic import (
17
+ BaseModel,
18
+ Field
19
+ )
20
+
21
+ metamodel_version = "None"
22
+ version = "None"
23
+
24
+
25
+ class ConfiguredBaseModel(BaseModel):
26
+ model_config = ConfigDict(
27
+ validate_assignment = True,
28
+ validate_default = True,
29
+ extra = "allow",
30
+ arbitrary_types_allowed = True,
31
+ use_enum_values = True,
32
+ strict = False,
33
+ )
34
+ pass
35
+
36
+
37
+ class Dates(ConfiguredBaseModel):
38
+
39
+ phase : str
40
+ from_ : int = Field(...,alias="from") # cause from is a keyword
41
+ to: Union[int,str]
42
+
43
+
44
+ class Member(ConfiguredBaseModel):
45
+
46
+ type : str
47
+ institution : str # id
48
+ dates : List[Dates] = Field(default_factory=list)
49
+ membership_type : str # prior, current
50
+
51
+ class Consortium(ConfiguredBaseModel):
52
+
53
+ id: str
54
+ validation_method: str = Field(default = "list")
55
+ type: str
56
+ name: Optional[str] = None
57
+ cmip_acronym: str = Field(...,alias="cmip-acronym")
58
+ status : Optional[str] = None
59
+ changes : Optional[str]
60
+ members : List[Member] = Field(default_factory=list)
61
+ url: Optional[str]
62
+
63
+
64
+ # Model rebuild
65
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
66
+ Consortium.model_rebuild()
@@ -0,0 +1,48 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+ from __future__ import annotations
9
+ from pydantic.version import VERSION as PYDANTIC_VERSION
10
+ if int(PYDANTIC_VERSION[0])>=2:
11
+ from pydantic import (
12
+ BaseModel,
13
+ ConfigDict
14
+ )
15
+ else:
16
+ from pydantic import (
17
+ BaseModel
18
+ )
19
+
20
+ metamodel_version = "None"
21
+ version = "None"
22
+
23
+
24
+ class ConfiguredBaseModel(BaseModel):
25
+ model_config = ConfigDict(
26
+ validate_assignment = True,
27
+ validate_default = True,
28
+ extra = "allow",
29
+ arbitrary_types_allowed = True,
30
+ use_enum_values = True,
31
+ strict = False,
32
+ )
33
+ pass
34
+
35
+
36
+
37
+
38
+
39
+ class Date(ConfiguredBaseModel):
40
+
41
+
42
+
43
+ id: str
44
+ type : str
45
+ regex : str
46
+ # Model rebuild
47
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
48
+ Date.model_rebuild()
@@ -0,0 +1,60 @@
1
+
2
+ from __future__ import annotations
3
+ from typing import (
4
+ List,
5
+ Optional
6
+ )
7
+ from pydantic.version import VERSION as PYDANTIC_VERSION
8
+ if int(PYDANTIC_VERSION[0])>=2:
9
+ from pydantic import (
10
+ BaseModel,
11
+ ConfigDict,
12
+ Field
13
+ )
14
+ else:
15
+ from pydantic import (
16
+ BaseModel,
17
+ Field
18
+ )
19
+
20
+ metamodel_version = "None"
21
+ version = "None"
22
+
23
+
24
+ class ConfiguredBaseModel(BaseModel):
25
+ model_config = ConfigDict(
26
+ validate_assignment = True,
27
+ validate_default = True,
28
+ extra = "allow",
29
+ arbitrary_types_allowed = True,
30
+ use_enum_values = True,
31
+ strict = False,
32
+ )
33
+ pass
34
+
35
+
36
+ class Experiment(ConfiguredBaseModel):
37
+ """
38
+ an 'experiment' refers to a specific, controlled simulation conducted using climate models to investigate particular aspects of the Earth's climate system. These experiments are designed with set parameters, such as initial conditions, external forcings (like greenhouse gas concentrations or solar radiation), and duration, to explore and understand climate behavior under various scenarios and conditions.
39
+ """
40
+
41
+ id: str
42
+ validation_method: str = Field(default ="list")
43
+ activity: List[str] = Field(default_factory=list)
44
+ description: str
45
+ tier: Optional[int]
46
+ experiment_id: str
47
+ sub_experiment_id: Optional[List[str]]
48
+ experiment: str
49
+ required_model_components: Optional[List[str]]
50
+ additionnal_allowed_model_components: Optional[List[str]] = Field(default_factory=list)
51
+ start_year: Optional[int]
52
+ end_year: Optional[int]
53
+ min_number_yrs_per_sim: Optional[int]
54
+ parent_activity_id: Optional[List[str]]
55
+ parent_experiment_id: Optional[List[str]]
56
+
57
+
58
+ # Model rebuild
59
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
60
+ Experiment.model_rebuild()
@@ -0,0 +1,47 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+ from __future__ import annotations
8
+ from pydantic.version import VERSION as PYDANTIC_VERSION
9
+ if int(PYDANTIC_VERSION[0])>=2:
10
+ from pydantic import (
11
+ BaseModel,
12
+ ConfigDict
13
+ )
14
+ else:
15
+ from pydantic import (
16
+ BaseModel
17
+ )
18
+
19
+ metamodel_version = "None"
20
+ version = "None"
21
+
22
+
23
+ class ConfiguredBaseModel(BaseModel):
24
+ model_config = ConfigDict(
25
+ validate_assignment = True,
26
+ validate_default = True,
27
+ extra = "allow",
28
+ arbitrary_types_allowed = True,
29
+ use_enum_values = True,
30
+ strict = False,
31
+ )
32
+ pass
33
+
34
+
35
+
36
+
37
+
38
+ class ForcingIndex(ConfiguredBaseModel):
39
+
40
+
41
+
42
+ id: str
43
+ type : str
44
+ regex : str
45
+ # Model rebuild
46
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
47
+ ForcingIndex.model_rebuild()
@@ -0,0 +1,45 @@
1
+
2
+ from __future__ import annotations
3
+ from pydantic.version import VERSION as PYDANTIC_VERSION
4
+ if int(PYDANTIC_VERSION[0])>=2:
5
+ from pydantic import (
6
+ BaseModel,
7
+ ConfigDict
8
+ )
9
+ else:
10
+ from pydantic import (
11
+ BaseModel
12
+ )
13
+
14
+ metamodel_version = "None"
15
+ version = "None"
16
+
17
+
18
+ class ConfiguredBaseModel(BaseModel):
19
+ model_config = ConfigDict(
20
+ validate_assignment = True,
21
+ validate_default = True,
22
+ extra = "allow",
23
+ arbitrary_types_allowed = True,
24
+ use_enum_values = True,
25
+ strict = False,
26
+ )
27
+ pass
28
+
29
+
30
+
31
+
32
+
33
+ class Frequency(ConfiguredBaseModel):
34
+
35
+
36
+
37
+ id: str
38
+ description :str
39
+ long_name :str
40
+ name : str
41
+ unit : str
42
+ type : str
43
+ # Model rebuild
44
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
45
+ Frequency.model_rebuild()