esgvoc 0.1.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.

Potentially problematic release.


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

Files changed (66) hide show
  1. esgvoc/__init__.py +1 -0
  2. esgvoc/api/__init__.py +62 -0
  3. esgvoc/api/_utils.py +39 -0
  4. esgvoc/api/data_descriptors/__init__.py +60 -0
  5. esgvoc/api/data_descriptors/activity.py +51 -0
  6. esgvoc/api/data_descriptors/consortium.py +66 -0
  7. esgvoc/api/data_descriptors/date.py +48 -0
  8. esgvoc/api/data_descriptors/experiment.py +60 -0
  9. esgvoc/api/data_descriptors/forcing_index.py +47 -0
  10. esgvoc/api/data_descriptors/frequency.py +45 -0
  11. esgvoc/api/data_descriptors/grid_label.py +46 -0
  12. esgvoc/api/data_descriptors/initialisation_index.py +46 -0
  13. esgvoc/api/data_descriptors/institution.py +58 -0
  14. esgvoc/api/data_descriptors/license.py +47 -0
  15. esgvoc/api/data_descriptors/mip_era.py +46 -0
  16. esgvoc/api/data_descriptors/model_component.py +47 -0
  17. esgvoc/api/data_descriptors/organisation.py +42 -0
  18. esgvoc/api/data_descriptors/physic_index.py +47 -0
  19. esgvoc/api/data_descriptors/product.py +45 -0
  20. esgvoc/api/data_descriptors/realisation_index.py +46 -0
  21. esgvoc/api/data_descriptors/realm.py +44 -0
  22. esgvoc/api/data_descriptors/resolution.py +46 -0
  23. esgvoc/api/data_descriptors/source.py +57 -0
  24. esgvoc/api/data_descriptors/source_type.py +43 -0
  25. esgvoc/api/data_descriptors/sub_experiment.py +43 -0
  26. esgvoc/api/data_descriptors/table.py +50 -0
  27. esgvoc/api/data_descriptors/time_range.py +28 -0
  28. esgvoc/api/data_descriptors/variable.py +77 -0
  29. esgvoc/api/data_descriptors/variant_label.py +49 -0
  30. esgvoc/api/projects.py +854 -0
  31. esgvoc/api/report.py +86 -0
  32. esgvoc/api/search.py +92 -0
  33. esgvoc/api/universe.py +218 -0
  34. esgvoc/apps/drs/__init__.py +16 -0
  35. esgvoc/apps/drs/models.py +43 -0
  36. esgvoc/apps/drs/parser.py +27 -0
  37. esgvoc/cli/config.py +79 -0
  38. esgvoc/cli/get.py +142 -0
  39. esgvoc/cli/install.py +14 -0
  40. esgvoc/cli/main.py +22 -0
  41. esgvoc/cli/status.py +26 -0
  42. esgvoc/cli/valid.py +156 -0
  43. esgvoc/core/constants.py +13 -0
  44. esgvoc/core/convert.py +0 -0
  45. esgvoc/core/data_handler.py +133 -0
  46. esgvoc/core/db/__init__.py +5 -0
  47. esgvoc/core/db/connection.py +31 -0
  48. esgvoc/core/db/models/mixins.py +18 -0
  49. esgvoc/core/db/models/project.py +65 -0
  50. esgvoc/core/db/models/universe.py +59 -0
  51. esgvoc/core/db/project_ingestion.py +152 -0
  52. esgvoc/core/db/universe_ingestion.py +120 -0
  53. esgvoc/core/logging.conf +21 -0
  54. esgvoc/core/logging_handler.py +4 -0
  55. esgvoc/core/repo_fetcher.py +259 -0
  56. esgvoc/core/service/__init__.py +8 -0
  57. esgvoc/core/service/data_merger.py +83 -0
  58. esgvoc/core/service/esg_voc.py +79 -0
  59. esgvoc/core/service/settings.py +64 -0
  60. esgvoc/core/service/settings.toml +12 -0
  61. esgvoc/core/service/settings_default.toml +20 -0
  62. esgvoc/core/service/state.py +222 -0
  63. esgvoc-0.1.2.dist-info/METADATA +54 -0
  64. esgvoc-0.1.2.dist-info/RECORD +66 -0
  65. esgvoc-0.1.2.dist-info/WHEEL +4 -0
  66. esgvoc-0.1.2.dist-info/entry_points.txt +2 -0
esgvoc/__init__.py ADDED
@@ -0,0 +1 @@
1
+ import esgvoc.core.logging_handler
esgvoc/api/__init__.py ADDED
@@ -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"]
esgvoc/api/_utils.py ADDED
@@ -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()
@@ -0,0 +1,46 @@
1
+
2
+
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 GridLabel(ConfiguredBaseModel):
35
+
36
+
37
+
38
+ id: str
39
+ description :str
40
+ short_name :str
41
+ name : str
42
+ region : str
43
+ type : str
44
+ # Model rebuild
45
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
46
+ GridLabel.model_rebuild()
@@ -0,0 +1,46 @@
1
+
2
+
3
+
4
+
5
+
6
+ from __future__ import annotations
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
+
34
+
35
+
36
+
37
+ class InitialisationIndex(ConfiguredBaseModel):
38
+
39
+
40
+
41
+ id: str
42
+ type : str
43
+ regex : str
44
+ # Model rebuild
45
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
46
+ InitialisationIndex.model_rebuild()
@@ -0,0 +1,58 @@
1
+
2
+
3
+ from __future__ import annotations
4
+ from typing import (
5
+ List,
6
+ Dict,
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
+ class Institution(ConfiguredBaseModel):
39
+
40
+ """
41
+ an registered institution for WCRP modelisation MIP
42
+ """
43
+
44
+
45
+ id: str
46
+ acronyms: List[str] = Field(default_factory=list)
47
+ aliases: Optional[List[str]] = Field(default_factory=list)
48
+ established: Optional[int]
49
+ type: Optional[str]
50
+ labels: Optional[List[str]] = Field(default_factory=list)
51
+ location: Optional[Dict] = Field(default_factory=dict)
52
+ name: str
53
+ ror: Optional[str]
54
+ url: Optional[List[str]] = Field(default_factory=list)
55
+
56
+ # Model rebuild
57
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
58
+ Institution.model_rebuild()
@@ -0,0 +1,47 @@
1
+
2
+
3
+ from __future__ import annotations
4
+ from typing import (
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
+
37
+ class License(ConfiguredBaseModel):
38
+
39
+ id: str
40
+ validation_method: str = Field(default = "list")
41
+ kind: str
42
+ license: Optional[str]
43
+ url: Optional[str]
44
+
45
+ # Model rebuild
46
+ # see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
47
+ License.model_rebuild()