esgvoc 0.1.2__py3-none-any.whl → 0.3.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.

Potentially problematic release.


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

Files changed (78) hide show
  1. esgvoc/__init__.py +3 -1
  2. esgvoc/api/__init__.py +30 -30
  3. esgvoc/api/_utils.py +28 -14
  4. esgvoc/api/data_descriptors/__init__.py +19 -10
  5. esgvoc/api/data_descriptors/activity.py +8 -45
  6. esgvoc/api/data_descriptors/area_label.py +6 -0
  7. esgvoc/api/data_descriptors/branded_suffix.py +5 -0
  8. esgvoc/api/data_descriptors/branded_variable.py +5 -0
  9. esgvoc/api/data_descriptors/consortium.py +16 -56
  10. esgvoc/api/data_descriptors/data_descriptor.py +106 -0
  11. esgvoc/api/data_descriptors/date.py +3 -46
  12. esgvoc/api/data_descriptors/directory_date.py +5 -0
  13. esgvoc/api/data_descriptors/experiment.py +19 -54
  14. esgvoc/api/data_descriptors/forcing_index.py +3 -45
  15. esgvoc/api/data_descriptors/frequency.py +6 -43
  16. esgvoc/api/data_descriptors/grid_label.py +6 -44
  17. esgvoc/api/data_descriptors/horizontal_label.py +6 -0
  18. esgvoc/api/data_descriptors/initialisation_index.py +3 -44
  19. esgvoc/api/data_descriptors/institution.py +11 -54
  20. esgvoc/api/data_descriptors/license.py +4 -44
  21. esgvoc/api/data_descriptors/mip_era.py +6 -44
  22. esgvoc/api/data_descriptors/model_component.py +7 -45
  23. esgvoc/api/data_descriptors/organisation.py +3 -40
  24. esgvoc/api/data_descriptors/physic_index.py +3 -45
  25. esgvoc/api/data_descriptors/product.py +4 -43
  26. esgvoc/api/data_descriptors/realisation_index.py +3 -44
  27. esgvoc/api/data_descriptors/realm.py +4 -42
  28. esgvoc/api/data_descriptors/resolution.py +6 -44
  29. esgvoc/api/data_descriptors/source.py +18 -53
  30. esgvoc/api/data_descriptors/source_type.py +3 -41
  31. esgvoc/api/data_descriptors/sub_experiment.py +3 -41
  32. esgvoc/api/data_descriptors/table.py +6 -48
  33. esgvoc/api/data_descriptors/temporal_label.py +6 -0
  34. esgvoc/api/data_descriptors/time_range.py +3 -27
  35. esgvoc/api/data_descriptors/variable.py +13 -71
  36. esgvoc/api/data_descriptors/variant_label.py +3 -47
  37. esgvoc/api/data_descriptors/vertical_label.py +5 -0
  38. esgvoc/api/project_specs.py +82 -0
  39. esgvoc/api/projects.py +284 -238
  40. esgvoc/api/report.py +89 -52
  41. esgvoc/api/search.py +31 -11
  42. esgvoc/api/universe.py +57 -48
  43. esgvoc/apps/__init__.py +6 -0
  44. esgvoc/apps/drs/__init__.py +0 -16
  45. esgvoc/apps/drs/constants.py +2 -0
  46. esgvoc/apps/drs/generator.py +429 -0
  47. esgvoc/apps/drs/report.py +492 -0
  48. esgvoc/apps/drs/validator.py +330 -0
  49. esgvoc/cli/drs.py +248 -0
  50. esgvoc/cli/get.py +26 -25
  51. esgvoc/cli/install.py +11 -8
  52. esgvoc/cli/main.py +4 -5
  53. esgvoc/cli/status.py +14 -2
  54. esgvoc/cli/valid.py +41 -45
  55. esgvoc/core/db/models/mixins.py +7 -0
  56. esgvoc/core/db/models/project.py +3 -8
  57. esgvoc/core/db/models/universe.py +3 -3
  58. esgvoc/core/db/project_ingestion.py +4 -1
  59. esgvoc/core/db/universe_ingestion.py +8 -7
  60. esgvoc/core/logging_handler.py +1 -1
  61. esgvoc/core/repo_fetcher.py +4 -3
  62. esgvoc/core/service/__init__.py +37 -5
  63. esgvoc/core/service/configuration/config_manager.py +188 -0
  64. esgvoc/core/service/configuration/setting.py +88 -0
  65. esgvoc/core/service/state.py +66 -42
  66. esgvoc-0.3.0.dist-info/METADATA +89 -0
  67. esgvoc-0.3.0.dist-info/RECORD +78 -0
  68. esgvoc-0.3.0.dist-info/licenses/LICENSE.txt +519 -0
  69. esgvoc/apps/drs/models.py +0 -43
  70. esgvoc/apps/drs/parser.py +0 -27
  71. esgvoc/cli/config.py +0 -79
  72. esgvoc/core/service/settings.py +0 -64
  73. esgvoc/core/service/settings.toml +0 -12
  74. esgvoc/core/service/settings_default.toml +0 -20
  75. esgvoc-0.1.2.dist-info/METADATA +0 -54
  76. esgvoc-0.1.2.dist-info/RECORD +0 -66
  77. {esgvoc-0.1.2.dist-info → esgvoc-0.3.0.dist-info}/WHEEL +0 -0
  78. {esgvoc-0.1.2.dist-info → esgvoc-0.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,57 +1,22 @@
1
+ from pydantic import Field
2
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
1
3
 
2
- from __future__ import annotations
3
- from typing import (
4
- List,
5
- Dict,
6
- Optional
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
4
 
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
- protected_namespaces = (),
34
- )
35
- pass
36
-
37
-
38
-
39
- class Source(ConfiguredBaseModel):
5
+ class Source(PlainTermDataDescriptor):
40
6
  """
41
- a 'source' refers to a numerical representations of the Earth's climate system. They simulate the interactions between the atmosphere, oceans, land surface, and ice. These models are based on fundamental physical, chemical, and biological processes and are used to understand past, present, and future climate conditions. Each source or model is typically associated with a specific research institution, center, or group. For instance, models like 'EC-Earth' are developed by a consortium of European institutes, while 'GFDL-CM4' is developed by the Geophysical Fluid Dynamics Laboratory (GFDL) in the United States.
7
+ A 'source' refers to a numerical representations of the Earth's climate system. They simulate \
8
+ the interactions between the atmosphere, oceans, land surface, and ice. These models are based \
9
+ on fundamental physical, chemical, and biological processes and are used to understand past, \
10
+ present, and future climate conditions. Each source or model is typically associated with a \
11
+ specific research institution, center, or group. For instance, models like 'EC-Earth' are \
12
+ developed by a consortium of European institutes, while 'GFDL-CM4' is developed by the \
13
+ Geophysical Fluid Dynamics Laboratory (GFDL) in the United States.
42
14
  """
43
-
44
- id: str
45
- validation_method: str = Field(default = "list")
46
- activity_participation: Optional[List[str]]
47
- cohort: List[str] = Field(default_factory=list)
48
- organisation_id: List[str] = Field(default_factory=list)
49
- label : str
50
- label_extended: Optional[str]
51
- license: Optional[Dict] = Field(default_factory=dict)
52
- model_component: Optional[dict]
53
- release_year: Optional[int]
54
-
55
- # Model rebuild
56
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
57
- Source.model_rebuild()
15
+ activity_participation: list[str]|None
16
+ cohort: list[str] = Field(default_factory=list)
17
+ organisation_id: list[str] = Field(default_factory=list)
18
+ label: str
19
+ label_extended: str|None
20
+ license: dict = Field(default_factory=dict)
21
+ model_component: dict|None
22
+ release_year: int|None
@@ -1,43 +1,5 @@
1
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
1
2
 
2
3
 
3
- from __future__ import annotations
4
- from pydantic.version import VERSION as PYDANTIC_VERSION
5
- if int(PYDANTIC_VERSION[0])>=2:
6
- from pydantic import (
7
- BaseModel,
8
- ConfigDict
9
- )
10
- else:
11
- from pydantic import (
12
- BaseModel
13
- )
14
-
15
- metamodel_version = "None"
16
- version = "None"
17
-
18
-
19
- class ConfiguredBaseModel(BaseModel):
20
- model_config = ConfigDict(
21
- validate_assignment = True,
22
- validate_default = True,
23
- extra = "allow",
24
- arbitrary_types_allowed = True,
25
- use_enum_values = True,
26
- strict = False,
27
- )
28
- pass
29
-
30
-
31
-
32
-
33
-
34
- class SourceType(ConfiguredBaseModel):
35
-
36
-
37
-
38
- id: str
39
- description :str
40
- type : str
41
- # Model rebuild
42
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
43
- SourceType.model_rebuild()
4
+ class SourceType(PlainTermDataDescriptor):
5
+ description: str
@@ -1,43 +1,5 @@
1
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
1
2
 
2
3
 
3
- from __future__ import annotations
4
- from pydantic.version import VERSION as PYDANTIC_VERSION
5
- if int(PYDANTIC_VERSION[0])>=2:
6
- from pydantic import (
7
- BaseModel,
8
- ConfigDict
9
- )
10
- else:
11
- from pydantic import (
12
- BaseModel
13
- )
14
-
15
- metamodel_version = "None"
16
- version = "None"
17
-
18
-
19
- class ConfiguredBaseModel(BaseModel):
20
- model_config = ConfigDict(
21
- validate_assignment = True,
22
- validate_default = True,
23
- extra = "allow",
24
- arbitrary_types_allowed = True,
25
- use_enum_values = True,
26
- strict = False,
27
- )
28
- pass
29
-
30
-
31
-
32
-
33
-
34
- class SubExperiment(ConfiguredBaseModel):
35
-
36
-
37
-
38
- id: str
39
- description :str
40
- type : str
41
- # Model rebuild
42
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
43
- SubExperiment.model_rebuild()
4
+ class SubExperiment(PlainTermDataDescriptor):
5
+ description: str
@@ -1,50 +1,8 @@
1
+ from pydantic import Field
2
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
1
3
 
2
4
 
3
-
4
- from __future__ import annotations
5
- from typing import (
6
- List,
7
- Optional
8
- )
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
- Field
15
- )
16
- else:
17
- from pydantic import (
18
- BaseModel,
19
- Field
20
- )
21
-
22
- metamodel_version = "None"
23
- version = "None"
24
-
25
-
26
- class ConfiguredBaseModel(BaseModel):
27
- model_config = ConfigDict(
28
- validate_assignment = True,
29
- validate_default = True,
30
- extra = "allow",
31
- arbitrary_types_allowed = True,
32
- use_enum_values = True,
33
- strict = False,
34
- )
35
- pass
36
-
37
-
38
-
39
- class Table(ConfiguredBaseModel):
40
-
41
- id: str
42
- validation_method: str = Field(default = "list")
43
- type: str
44
- product: Optional[str]
45
- table_date: Optional[str]
46
-
47
- variable_entry: List[str] = Field(default_factory=list)
48
- # Model rebuild
49
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
50
- Table.model_rebuild()
5
+ class Table(PlainTermDataDescriptor):
6
+ product: str|None
7
+ table_date: str|None
8
+ variable_entry: list[str] = Field(default_factory=list)
@@ -0,0 +1,6 @@
1
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
2
+
3
+
4
+ class TemporalLabel(PlainTermDataDescriptor):
5
+ description: str
6
+ label: str
@@ -1,28 +1,4 @@
1
- from pydantic import BaseModel, ConfigDict
1
+ from esgvoc.api.data_descriptors.data_descriptor import CompositeTermDataDescriptor
2
2
 
3
- class ConfiguredBaseModel(BaseModel):
4
- model_config = ConfigDict(
5
- validate_assignment = True,
6
- validate_default = True,
7
- extra = "allow",
8
- arbitrary_types_allowed = True,
9
- use_enum_values = True,
10
- strict = False,
11
- )
12
- pass
13
-
14
- class Part(ConfiguredBaseModel):
15
- id: str
16
- type : str
17
- is_required : bool
18
-
19
- class TimeRange(ConfiguredBaseModel):
20
- id: str
21
- separator: str
22
- type: str
23
- parts: list[Part]
24
-
25
-
26
- # Model rebuild
27
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
28
- TimeRange.model_rebuild()
3
+ class TimeRange(CompositeTermDataDescriptor):
4
+ description: str
@@ -1,77 +1,19 @@
1
+ from pydantic import Field
2
+ from esgvoc.api.data_descriptors.data_descriptor import PlainTermDataDescriptor
1
3
 
2
- from __future__ import annotations
3
- from typing import (
4
- Any,
5
- Dict,
6
- Optional
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
- RootModel
15
- )
16
- else:
17
- from pydantic import (
18
- BaseModel,
19
- Field
20
- )
21
4
 
22
- metamodel_version = "None"
23
- version = "None"
24
-
25
-
26
- class ConfiguredBaseModel(BaseModel):
27
- model_config = ConfigDict(
28
- validate_assignment = True,
29
- validate_default = True,
30
- extra = "allow",
31
- arbitrary_types_allowed = True,
32
- use_enum_values = True,
33
- strict = False,
34
- )
35
- pass
36
-
37
-
38
-
39
-
40
- class LinkMLMeta(RootModel):
41
- root: Dict[str, Any] = {}
42
- model_config = ConfigDict(frozen=True)
43
-
44
- def __getattr__(self, key:str):
45
- return getattr(self.root, key)
46
-
47
- def __getitem__(self, key:str):
48
- return self.root[key]
49
-
50
- def __setitem__(self, key:str, value):
51
- self.root[key] = value
52
-
53
- def __contains__(self, key:str) -> bool:
54
- return key in self.root
55
-
56
-
57
- class Variable(ConfiguredBaseModel):
5
+ class Variable(PlainTermDataDescriptor):
58
6
  """
59
-
60
- a variable refers to a specific type of climate-related quantity or measurement that is simulated and stored in a data file. These variables represent key physical, chemical, or biological properties of the Earth system and are outputs from climate models.
61
- Each variable captures a different aspect of the climate system, such as temperature, precipitation, sea level, radiation, or atmospheric composition.
62
- Examples of Variables: tas: Near-surface air temperature (often measured at 2 meters above the surface) pr: Precipitation psl: Sea level pressure zg: Geopotential height rlut: Top-of-atmosphere longwave radiation siconc: Sea ice concentration co2: Atmospheric CO2 concentration
63
-
7
+ A variable refers to a specific type of climate-related quantity or measurement that is \
8
+ simulated and stored in a data file. These variables represent key physical, chemical, or \
9
+ biological properties of the Earth system and are outputs from climate models.
10
+ Each variable captures a different aspect of the climate system, such as temperature, \
11
+ precipitation, sea level, radiation, or atmospheric composition.
12
+ Examples of Variables: tas: Near-surface air temperature (often measured at 2 meters above \
13
+ the surface) pr: Precipitation psl: Sea level pressure zg: Geopotential height rlut: \
14
+ Top-of-atmosphere longwave radiation siconc: Sea ice concentration co2: Atmospheric CO2 concentration
64
15
  """
65
-
66
- id: str
67
- cmip_acronym: str
68
16
  validation_method: str = Field(default = "list")
69
17
  long_name: str
70
- standard_name: Optional[str]
71
- type: str
72
- units: Optional[str]
73
-
74
-
75
- # Model rebuild
76
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
77
- Variable.model_rebuild()
18
+ standard_name: str|None
19
+ units: str|None
@@ -1,49 +1,5 @@
1
+ from esgvoc.api.data_descriptors.data_descriptor import CompositeTermDataDescriptor
1
2
 
2
3
 
3
- from __future__ import annotations
4
- from typing import (
5
- List
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
- )
13
- else:
14
- from pydantic import (
15
- BaseModel
16
- )
17
-
18
- metamodel_version = "None"
19
- version = "None"
20
-
21
-
22
- class ConfiguredBaseModel(BaseModel):
23
- model_config = ConfigDict(
24
- validate_assignment = True,
25
- validate_default = True,
26
- extra = "allow",
27
- arbitrary_types_allowed = True,
28
- use_enum_values = True,
29
- strict = False,
30
- )
31
- pass
32
-
33
- class Part(ConfiguredBaseModel):
34
- id: str
35
- type : str
36
- is_required : bool
37
-
38
- class VariantLabel(ConfiguredBaseModel):
39
-
40
-
41
- id: str
42
- separator: str
43
- type: str
44
- parts: List[Part]
45
-
46
-
47
- # Model rebuild
48
- # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
49
- VariantLabel.model_rebuild()
4
+ class VariantLabel(CompositeTermDataDescriptor):
5
+ description: str
@@ -0,0 +1,5 @@
1
+ from esgvoc.api.data_descriptors.data_descriptor import PatternTermDataDescriptor
2
+
3
+
4
+ class VerticalLabel(PatternTermDataDescriptor):
5
+ pass
@@ -0,0 +1,82 @@
1
+ from enum import Enum
2
+ from typing import Annotated, Literal
3
+
4
+ from pydantic import BaseModel, ConfigDict, Field
5
+
6
+
7
+ class DrsType(str, Enum):
8
+ """
9
+ The types of DRS specification (directory, file name and dataset id).
10
+ """
11
+ DIRECTORY = "directory"
12
+ """The DRS directory specification type."""
13
+ FILE_NAME = "file_name"
14
+ """The DRS file name specification type."""
15
+ DATASET_ID = "dataset_id"
16
+ """The DRS dataset id specification type."""
17
+
18
+
19
+ class DrsPartKind(str, Enum):
20
+ """
21
+ The kinds of DRS part (constant and collection).
22
+ """
23
+ CONSTANT = "constant"
24
+ """The constant part type."""
25
+ COLLECTION = "collection"
26
+ """The collection part type."""
27
+
28
+
29
+ class DrsConstant(BaseModel):
30
+ """
31
+ A constant part of a DRS specification (e.g., cmip5).
32
+ """
33
+ value: str
34
+ """The value of the a constant part."""
35
+ kind: Literal[DrsPartKind.CONSTANT] = DrsPartKind.CONSTANT
36
+ """The DRS part kind."""
37
+ def __str__(self) -> str:
38
+ return self.value
39
+
40
+
41
+ class DrsCollection(BaseModel):
42
+ """
43
+ A collection part of a DRS specification (e.g., institution_id for CMIP6).
44
+ """
45
+ collection_id: str
46
+ """The collection id."""
47
+ is_required: bool
48
+ """Whether the collection is required for the DRS specification or not."""
49
+ kind: Literal[DrsPartKind.COLLECTION] = DrsPartKind.COLLECTION
50
+ """The DRS part kind."""
51
+ def __str__(self) -> str:
52
+ return self.collection_id
53
+
54
+
55
+ DrsPart = Annotated[DrsConstant | DrsCollection, Field(discriminator="kind")]
56
+ """A fragment of a DRS specification"""
57
+
58
+
59
+ class DrsSpecification(BaseModel):
60
+ """
61
+ A DRS specification.
62
+ """
63
+ type: DrsType
64
+ """The type of the specification."""
65
+ separator: str
66
+ """The textual separator string or character."""
67
+ properties: dict|None = None
68
+ """The other specifications (e.g., file name extension for file name DRS specification)."""
69
+ parts: list[DrsPart]
70
+ """The parts of the DRS specification."""
71
+
72
+ class ProjectSpecs(BaseModel):
73
+ """
74
+ A project specifications.
75
+ """
76
+ project_id: str
77
+ """The project id."""
78
+ description: str
79
+ """The description of the project."""
80
+ drs_specs: list[DrsSpecification]
81
+ """The DRS specifications of the project (directory, file name and dataset id."""
82
+ model_config = ConfigDict(extra = "allow")