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
esgvoc/api/report.py CHANGED
@@ -1,86 +1,123 @@
1
1
  from abc import ABC, abstractmethod
2
- from typing import Any
2
+ from typing import Any, Protocol
3
+
4
+ from pydantic import BaseModel, computed_field
3
5
 
4
6
  import esgvoc.core.constants as api_settings
5
7
  from esgvoc.core.db.models.mixins import TermKind
6
- from esgvoc.core.db.models.project import PTerm
7
- from esgvoc.core.db.models.universe import UTerm
8
8
 
9
9
 
10
- class ValidationErrorVisitor(ABC):
11
- @abstractmethod
10
+ class ValidationErrorVisitor(Protocol):
11
+ """
12
+ Specifications for a term validation error visitor.
13
+ """
12
14
  def visit_universe_term_error(self, error: "UniverseTermError") -> Any:
15
+ """Visit a universe term error."""
13
16
  pass
14
17
 
15
- @abstractmethod
16
18
  def visit_project_term_error(self, error: "ProjectTermError") -> Any:
19
+ """Visit a project term error."""
17
20
  pass
18
21
 
19
22
 
20
- class BasicValidationErrorVisitor(ValidationErrorVisitor):
21
- def visit_universe_term_error(self, error: "UniverseTermError") -> Any:
22
- term_id = error.term[api_settings.TERM_ID_JSON_KEY]
23
- result = f"The term {term_id} from the data descriptor {error.data_descriptor_id} "+\
24
- f"does not validate the given value '{error.value}'"
25
- return result
26
-
27
- def visit_project_term_error(self, error: "ProjectTermError") -> Any:
28
- term_id = error.term[api_settings.TERM_ID_JSON_KEY]
29
- result = f"The term {term_id} from the collection {error.collection_id} "+\
30
- f"does not validate the given value '{error.value}'"
31
- return result
32
-
33
-
34
- class ValidationError(ABC):
35
- def __init__(self,
36
- value: str):
37
- self.value: str = value
38
-
23
+ class ValidationError(BaseModel, ABC):
24
+ """
25
+ Generic class for the term validation error.
26
+ """
27
+ value: str
28
+ """The given value that is invalid."""
29
+ term: dict
30
+ """JSON specification of the term."""
31
+ term_kind: TermKind
32
+ """The kind of term."""
33
+ @computed_field # type: ignore
34
+ @property
35
+ def class_name(self) -> str:
36
+ """The class name of the issue for JSON serialization."""
37
+ return self.__class__.__name__
39
38
  @abstractmethod
40
39
  def accept(self, visitor: ValidationErrorVisitor) -> Any:
40
+ """
41
+ Accept a validation error visitor.
42
+
43
+ :param visitor: The validation error visitor.
44
+ :type visitor: ValidationErrorVisitor
45
+ :return: Depending on the visitor.
46
+ :rtype: Any
47
+ """
41
48
  pass
42
49
 
43
50
  class UniverseTermError(ValidationError):
44
- def __init__(self,
45
- value: str,
46
- term: UTerm):
47
- super().__init__(value)
48
- self.term: dict = term.specs
49
- self.term_kind: TermKind = term.kind
50
- self.data_descriptor_id: str = term.data_descriptor.id
51
+ """
52
+ A validation error on a term from the universe.
53
+ """
54
+
55
+ data_descriptor_id: str
56
+ """The data descriptor that the term belongs."""
51
57
 
52
58
  def accept(self, visitor: ValidationErrorVisitor) -> Any:
53
59
  return visitor.visit_universe_term_error(self)
54
60
 
61
+ def __str__(self) -> str:
62
+ term_id = self.term[api_settings.TERM_ID_JSON_KEY]
63
+ result = f"The term {term_id} from the data descriptor {self.data_descriptor_id} "+\
64
+ f"does not validate the given value '{self.value}'"
65
+ return result
66
+ def __repr__(self) -> str:
67
+ return self.__str__()
68
+
55
69
 
56
70
  class ProjectTermError(ValidationError):
57
- def __init__(self,
58
- value: str,
59
- term: PTerm):
60
- super().__init__(value)
61
- self.term: dict = term.specs
62
- self.term_kind: TermKind = term.kind
63
- self.collection_id: str = term.collection.id
71
+ """
72
+ A validation error on a term from a project.
73
+ """
74
+
75
+ collection_id: str
76
+ """The collection id that the term belongs"""
64
77
 
65
78
  def accept(self, visitor: ValidationErrorVisitor) -> Any:
66
79
  return visitor.visit_project_term_error(self)
67
80
 
81
+ def __str__(self) -> str:
82
+ term_id = self.term[api_settings.TERM_ID_JSON_KEY]
83
+ result = f"The term {term_id} from the collection {self.collection_id} "+\
84
+ f"does not validate the given value '{self.value}'"
85
+ return result
86
+ def __repr__(self) -> str:
87
+ return self.__str__()
88
+
89
+
90
+ class ValidationReport(BaseModel):
91
+ """
92
+ Term validation report.
93
+ """
94
+
95
+ expression: str
96
+ """The given expression."""
97
+
98
+ errors: list[UniverseTermError|ProjectTermError]
99
+ """The validation errors."""
100
+
101
+ @computed_field # type: ignore
102
+ @property
103
+ def nb_errors(self) -> int:
104
+ """The number of validation errors."""
105
+ return len(self.errors) if self.errors else 0
106
+
107
+ @computed_field # type: ignore
108
+ @property
109
+ def validated(self) -> bool:
110
+ """The expression is validated or not."""
111
+ return False if self.errors else True
68
112
 
69
- class ValidationReport:
70
- def __init__(self,
71
- given_expression: str,
72
- errors: list[ValidationError]):
73
- self.expression: str = given_expression
74
- self.errors: list[ValidationError] = errors
75
- self.nb_errors = len(self.errors) if self.errors else 0
76
- self.validated: bool = False if errors else True
77
- self.message = f"'{self.expression}' has {self.nb_errors} error(s)"
78
-
79
113
  def __len__(self) -> int:
80
114
  return self.nb_errors
81
-
115
+
82
116
  def __bool__(self) -> bool:
83
117
  return self.validated
84
-
118
+
119
+ def __str__(self) -> str:
120
+ return f"'{self.expression}' has {self.nb_errors} error(s)"
121
+
85
122
  def __repr__(self) -> str:
86
- return self.message
123
+ return self.__str__()
esgvoc/api/search.py CHANGED
@@ -1,35 +1,55 @@
1
- from dataclasses import dataclass
1
+ from typing import Iterable
2
2
  from enum import Enum
3
-
4
3
  from pydantic import BaseModel
5
4
  from sqlalchemy import ColumnElement, func
6
5
  from sqlmodel import col
7
6
 
8
7
 
9
- @dataclass
10
- class MatchingTerm:
8
+ class MatchingTerm(BaseModel):
9
+ """
10
+ Place holder for a term that matches a value (term validation).
11
+ """
11
12
  project_id: str
13
+ """The project id to which the term belongs."""
12
14
  collection_id: str
15
+ """The collection id to which the term belongs."""
13
16
  term_id: str
17
+ """The term id."""
14
18
 
15
19
 
16
20
  class SearchType(Enum):
17
- EXACT = ("exact",)
18
- LIKE = ("like",) # can interpret %
19
- STARTS_WITH = ("starts_with",) # can interpret %
21
+ """
22
+ The search types used for to find terms.
23
+ """
24
+ EXACT = "exact"
25
+ """Performs exact match."""
26
+ LIKE = "like" # can interpret %
27
+ """As SQL operator, it can interpret % as a wildcard."""
28
+ STARTS_WITH = "starts_with" # can interpret %
29
+ """Prefix based search."""
20
30
  ENDS_WITH = "ends_with" # can interpret %
21
- REGEX = ("regex",)
31
+ """Suffix based search."""
32
+ REGEX = "regex"
33
+ """Search based on regex."""
22
34
 
23
35
 
24
36
  class SearchSettings(BaseModel):
37
+ """
38
+ Search configuration.
39
+ """
25
40
  type: SearchType = SearchType.EXACT
41
+ """The type of search."""
26
42
  case_sensitive: bool = True
43
+ """Enable case sensitivity or not."""
27
44
  not_operator: bool = False
45
+ """Give the opposite result like the NOT SQL operator."""
46
+ selected_term_fields: Iterable[str]|None = None
47
+ """Term fields to select"""
28
48
 
29
49
 
30
- def create_str_comparison_expression(field: str,
31
- value: str,
32
- settings: SearchSettings|None) -> ColumnElement:
50
+ def _create_str_comparison_expression(field: str,
51
+ value: str,
52
+ settings: SearchSettings|None) -> ColumnElement:
33
53
  '''
34
54
  SQLite LIKE is case insensitive (and so STARTS/ENDS_WITH which are implemented with LIKE).
35
55
  So the case sensitive LIKE is implemented with REGEX.
esgvoc/api/universe.py CHANGED
@@ -1,10 +1,10 @@
1
- from typing import Sequence
1
+ from typing import Sequence, Iterable
2
2
 
3
3
  from esgvoc.api._utils import (get_universe_session,
4
4
  instantiate_pydantic_terms)
5
- from esgvoc.api.search import SearchSettings, create_str_comparison_expression
6
- from esgvoc.core.db.models.universe import DataDescriptor, UTerm
7
- from pydantic import BaseModel
5
+ from esgvoc.api.search import SearchSettings, _create_str_comparison_expression
6
+ from esgvoc.api.data_descriptors.data_descriptor import DataDescriptor
7
+ from esgvoc.core.db.models.universe import UDataDescriptor, UTerm
8
8
  from sqlmodel import Session, select
9
9
 
10
10
 
@@ -13,10 +13,10 @@ def _find_terms_in_data_descriptor(data_descriptor_id: str,
13
13
  session: Session,
14
14
  settings: SearchSettings|None) -> Sequence[UTerm]:
15
15
  """Settings only apply on the term_id comparison."""
16
- where_expression = create_str_comparison_expression(field=UTerm.id,
17
- value=term_id,
18
- settings=settings)
19
- statement = select(UTerm).join(DataDescriptor).where(DataDescriptor.id==data_descriptor_id,
16
+ where_expression = _create_str_comparison_expression(field=UTerm.id,
17
+ value=term_id,
18
+ settings=settings)
19
+ statement = select(UTerm).join(UDataDescriptor).where(UDataDescriptor.id==data_descriptor_id,
20
20
  where_expression)
21
21
  results = session.exec(statement)
22
22
  result = results.all()
@@ -26,7 +26,7 @@ def _find_terms_in_data_descriptor(data_descriptor_id: str,
26
26
  def find_terms_in_data_descriptor(data_descriptor_id: str,
27
27
  term_id: str,
28
28
  settings: SearchSettings|None = None) \
29
- -> list[BaseModel]:
29
+ -> list[DataDescriptor]:
30
30
  """
31
31
  Finds one or more terms in the given data descriptor based on the specified search settings.
32
32
  This function performs an exact match on the `data_descriptor_id` and
@@ -39,9 +39,9 @@ def find_terms_in_data_descriptor(data_descriptor_id: str,
39
39
  returns an empty list.
40
40
 
41
41
  Behavior based on search type:
42
- - `EXACT` and absence of `settings`: returns zero or one Pydantic term instance in the list.
43
- - `REGEX`, `LIKE`, `STARTS_WITH` and `ENDS_WITH`: returns zero, one or more Pydantic term
44
- instances in the list.
42
+ - `EXACT` and absence of `settings`: returns zero or one term instance in the list.
43
+ - `REGEX`, `LIKE`, `STARTS_WITH` and `ENDS_WITH`: returns zero, one or more term \
44
+ instances in the list.
45
45
 
46
46
  :param data_descriptor_id: A data descriptor id
47
47
  :type data_descriptor_id: str
@@ -49,23 +49,22 @@ def find_terms_in_data_descriptor(data_descriptor_id: str,
49
49
  :type term_id: str
50
50
  :param settings: The search settings
51
51
  :type settings: SearchSettings|None
52
- :returns: A list of Pydantic model term instances.
53
- Returns an empty list if no matches are found.
54
- :rtype: list[BaseModel]
52
+ :returns: A list of term instances. Returns an empty list if no matches are found.
53
+ :rtype: list[DataDescriptor]
55
54
  """
56
- result: list[BaseModel] = list()
55
+ result: list[DataDescriptor] = list()
57
56
  with get_universe_session() as session:
58
57
  terms = _find_terms_in_data_descriptor(data_descriptor_id, term_id, session, settings)
59
- instantiate_pydantic_terms(terms, result)
58
+ instantiate_pydantic_terms(terms, result, settings.selected_term_fields if settings else None)
60
59
  return result
61
60
 
62
61
 
63
62
  def _find_terms_in_universe(term_id: str,
64
63
  session: Session,
65
64
  settings: SearchSettings|None) -> Sequence[UTerm]:
66
- where_expression = create_str_comparison_expression(field=UTerm.id,
67
- value=term_id,
68
- settings=settings)
65
+ where_expression = _create_str_comparison_expression(field=UTerm.id,
66
+ value=term_id,
67
+ settings=settings)
69
68
  statement = select(UTerm).where(where_expression)
70
69
  results = session.exec(statement).all()
71
70
  return results
@@ -73,7 +72,7 @@ def _find_terms_in_universe(term_id: str,
73
72
 
74
73
  def find_terms_in_universe(term_id: str,
75
74
  settings: SearchSettings|None = None) \
76
- -> list[BaseModel]:
75
+ -> list[DataDescriptor]:
77
76
  """
78
77
  Finds one or more terms of the universe.
79
78
  The given `term_id` is searched according to the search type specified in
@@ -87,36 +86,38 @@ def find_terms_in_universe(term_id: str,
87
86
  :type term_id: str
88
87
  :param settings: The search settings
89
88
  :type settings: SearchSettings|None
90
- :returns: A list of Pydantic term instances. Returns an empty list if no matches are found.
91
- :rtype: list[BaseModel]
89
+ :returns: A list of term instances. Returns an empty list if no matches are found.
90
+ :rtype: list[DataDescriptor]
92
91
  """
93
- result: list[BaseModel] = list()
92
+ result: list[DataDescriptor] = list()
94
93
  with get_universe_session() as session:
95
94
  terms = _find_terms_in_universe(term_id, session, settings)
96
- instantiate_pydantic_terms(terms, result)
95
+ instantiate_pydantic_terms(terms, result, settings.selected_term_fields if settings else None)
97
96
  return result
98
97
 
99
98
 
100
- def _get_all_terms_in_data_descriptor(data_descriptor: DataDescriptor) -> list[BaseModel]:
101
- result: list[BaseModel] = list()
102
- instantiate_pydantic_terms(data_descriptor.terms, result)
99
+ def _get_all_terms_in_data_descriptor(data_descriptor: UDataDescriptor,
100
+ selected_term_fields: Iterable[str]|None) -> list[DataDescriptor]:
101
+ result: list[DataDescriptor] = list()
102
+ instantiate_pydantic_terms(data_descriptor.terms, result, selected_term_fields)
103
103
  return result
104
104
 
105
105
 
106
106
  def _find_data_descriptors_in_universe(data_descriptor_id: str,
107
107
  session: Session,
108
- settings: SearchSettings|None) -> Sequence[DataDescriptor]:
109
- where_expression = create_str_comparison_expression(field=DataDescriptor.id,
110
- value=data_descriptor_id,
111
- settings=settings)
112
- statement = select(DataDescriptor).where(where_expression)
108
+ settings: SearchSettings|None) -> Sequence[UDataDescriptor]:
109
+ where_expression = _create_str_comparison_expression(field=UDataDescriptor.id,
110
+ value=data_descriptor_id,
111
+ settings=settings)
112
+ statement = select(UDataDescriptor).where(where_expression)
113
113
  results = session.exec(statement)
114
114
  result = results.all()
115
115
  return result
116
116
 
117
117
 
118
- def get_all_terms_in_data_descriptor(data_descriptor_id: str) \
119
- -> list[BaseModel]:
118
+ def get_all_terms_in_data_descriptor(data_descriptor_id: str,
119
+ selected_term_fields: Iterable[str]|None = None) \
120
+ -> list[DataDescriptor]:
120
121
  """
121
122
  Gets all the terms of the given data descriptor.
122
123
  This function performs an exact match on the `data_descriptor_id` and does **not** search
@@ -125,8 +126,11 @@ def get_all_terms_in_data_descriptor(data_descriptor_id: str) \
125
126
 
126
127
  :param data_descriptor_id: A data descriptor id
127
128
  :type data_descriptor_id: str
128
- :returns: a list of Pydantic term instances. Returns an empty list if no matches are found.
129
- :rtype: list[BaseModel]
129
+ :param selected_term_fields: A list of term fields to select or `None`. If `None`, all the \
130
+ fields of the terms are returned.
131
+ :type selected_term_fields: Iterable[str]|None
132
+ :returns: a list of term instances. Returns an empty list if no matches are found.
133
+ :rtype: list[DataDescriptor]
130
134
  """
131
135
  with get_universe_session() as session:
132
136
  data_descriptors = _find_data_descriptors_in_universe(data_descriptor_id,
@@ -134,7 +138,7 @@ def get_all_terms_in_data_descriptor(data_descriptor_id: str) \
134
138
  None)
135
139
  if data_descriptors:
136
140
  data_descriptor = data_descriptors[0]
137
- result = _get_all_terms_in_data_descriptor(data_descriptor)
141
+ result = _get_all_terms_in_data_descriptor(data_descriptor, selected_term_fields)
138
142
  else:
139
143
  result = list()
140
144
  return result
@@ -153,9 +157,9 @@ def find_data_descriptors_in_universe(data_descriptor_id: str,
153
157
  If the provided `data_descriptor_id` is not found, the function returns an empty list.
154
158
 
155
159
  Behavior based on search type:
156
- - `EXACT` and absence of `settings`: returns zero or one data descriptor context in the list.
157
- - `REGEX`, `LIKE`, `STARTS_WITH` and `ENDS_WITH`: returns zero, one or more
158
- data descriptor contexts in the list.
160
+ - `EXACT` and absence of `settings`: returns zero or one data descriptor context in the list.
161
+ - `REGEX`, `LIKE`, `STARTS_WITH` and `ENDS_WITH`: returns zero, one or more \
162
+ data descriptor contexts in the list.
159
163
 
160
164
  :param data_descriptor_id: A data descriptor id to be found
161
165
  :type data_descriptor_id: str
@@ -174,8 +178,8 @@ def find_data_descriptors_in_universe(data_descriptor_id: str,
174
178
  return result
175
179
 
176
180
 
177
- def _get_all_data_descriptors_in_universe(session: Session) -> Sequence[DataDescriptor]:
178
- statement = select(DataDescriptor)
181
+ def _get_all_data_descriptors_in_universe(session: Session) -> Sequence[UDataDescriptor]:
182
+ statement = select(UDataDescriptor)
179
183
  data_descriptors = session.exec(statement)
180
184
  result = data_descriptors.all()
181
185
  return result
@@ -196,23 +200,28 @@ def get_all_data_descriptors_in_universe() -> list[str]:
196
200
  return result
197
201
 
198
202
 
199
- def get_all_terms_in_universe() -> list[BaseModel]:
203
+ def get_all_terms_in_universe(selected_term_fields: Iterable[str]|None = None) -> list[DataDescriptor]:
200
204
  """
201
205
  Gets all the terms of the universe.
202
206
  Terms are unique within a data descriptor but may have some synonyms in the universe.
203
207
 
204
- :returns: A list of Pydantic term instances.
205
- :rtype: list[BaseModel]
208
+ :param selected_term_fields: A list of term fields to select or `None`. If `None`, all the \
209
+ fields of the terms are returned.
210
+ :type selected_term_fields: Iterable[str]|None
211
+ :returns: A list of term instances.
212
+ :rtype: list[DataDescriptor]
206
213
  """
207
214
  result = list()
208
215
  with get_universe_session() as session:
209
216
  data_descriptors = _get_all_data_descriptors_in_universe(session)
210
217
  for data_descriptor in data_descriptors:
211
218
  # Term may have some synonyms within the whole universe.
212
- terms = _get_all_terms_in_data_descriptor(data_descriptor)
219
+ terms = _get_all_terms_in_data_descriptor(data_descriptor, selected_term_fields)
213
220
  result.extend(terms)
214
221
  return result
215
222
 
216
223
 
217
224
  if __name__ == "__main__":
218
- print(find_terms_in_data_descriptor('institution', 'ipsl'))
225
+ settings = SearchSettings()
226
+ settings.selected_term_fields = ('id',)
227
+ print(find_terms_in_data_descriptor('institution', 'ipsl', settings))
@@ -0,0 +1,6 @@
1
+
2
+ from esgvoc.apps.drs.generator import DrsGenerator
3
+ from esgvoc.apps.drs.report import DrsGenerationReport, DrsValidationReport
4
+ from esgvoc.apps.drs.validator import DrsValidator
5
+
6
+ __all__ = ["DrsValidator", "DrsValidationReport", "DrsGenerator", "DrsGenerationReport"]
@@ -1,16 +0,0 @@
1
- from esgvoc.apps.drs.models import (DrsType,
2
- DrsPartType,
3
- DrsConstant,
4
- DrsCollection,
5
- DrsPart,
6
- DrsSpecification,
7
- ProjectSpecs)
8
-
9
-
10
- __all__ = ["DrsType",
11
- "DrsPartType",
12
- "DrsConstant",
13
- "DrsCollection",
14
- "DrsPart",
15
- "DrsSpecification",
16
- "ProjectSpecs"]
@@ -0,0 +1,2 @@
1
+ FILE_NAME_EXTENSION_KEY = 'extension'
2
+ FILE_NAME_EXTENSION_SEPARATOR_KEY = 'extension_separator'