esgvoc 1.0.1__py3-none-any.whl → 1.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 (41) hide show
  1. esgvoc/__init__.py +1 -1
  2. esgvoc/api/__init__.py +0 -6
  3. esgvoc/api/data_descriptors/__init__.py +6 -0
  4. esgvoc/api/data_descriptors/archive.py +5 -0
  5. esgvoc/api/data_descriptors/citation_url.py +5 -0
  6. esgvoc/api/data_descriptors/experiment.py +2 -2
  7. esgvoc/api/data_descriptors/known_branded_variable.py +58 -5
  8. esgvoc/api/data_descriptors/regex.py +5 -0
  9. esgvoc/api/data_descriptors/vertical_label.py +2 -2
  10. esgvoc/api/project_specs.py +48 -130
  11. esgvoc/api/projects.py +104 -63
  12. esgvoc/apps/drs/generator.py +47 -42
  13. esgvoc/apps/drs/validator.py +22 -38
  14. esgvoc/apps/jsg/json_schema_generator.py +252 -136
  15. esgvoc/apps/jsg/templates/template.jinja +249 -0
  16. esgvoc/apps/test_cv/README.md +214 -0
  17. esgvoc/apps/test_cv/cv_tester.py +1368 -0
  18. esgvoc/apps/test_cv/example_usage.py +216 -0
  19. esgvoc/apps/vr/__init__.py +12 -0
  20. esgvoc/apps/vr/build_variable_registry.py +71 -0
  21. esgvoc/apps/vr/example_usage.py +60 -0
  22. esgvoc/apps/vr/vr_app.py +333 -0
  23. esgvoc/cli/config.py +671 -86
  24. esgvoc/cli/drs.py +39 -21
  25. esgvoc/cli/main.py +2 -0
  26. esgvoc/cli/test_cv.py +257 -0
  27. esgvoc/core/constants.py +10 -7
  28. esgvoc/core/data_handler.py +24 -22
  29. esgvoc/core/db/connection.py +7 -0
  30. esgvoc/core/db/project_ingestion.py +34 -9
  31. esgvoc/core/db/universe_ingestion.py +1 -2
  32. esgvoc/core/service/configuration/setting.py +192 -21
  33. esgvoc/core/service/data_merger.py +1 -1
  34. esgvoc/core/service/state.py +18 -2
  35. {esgvoc-1.0.1.dist-info → esgvoc-1.1.2.dist-info}/METADATA +3 -1
  36. {esgvoc-1.0.1.dist-info → esgvoc-1.1.2.dist-info}/RECORD +40 -29
  37. esgvoc/apps/jsg/cmip6_template.json +0 -74
  38. /esgvoc/apps/{py.typed → test_cv/__init__.py} +0 -0
  39. {esgvoc-1.0.1.dist-info → esgvoc-1.1.2.dist-info}/WHEEL +0 -0
  40. {esgvoc-1.0.1.dist-info → esgvoc-1.1.2.dist-info}/entry_points.txt +0 -0
  41. {esgvoc-1.0.1.dist-info → esgvoc-1.1.2.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,249 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://stac-extensions.github.io/{{ project_id|lower }}/{{ catalog_version }}/schema.json#",
4
+ "title": "{{ project_id|upper }} Extension",
5
+ "description": "STAC {{ project_id|upper }} Extension for STAC Items and STAC Collection Summaries.",
6
+ "type": "object",
7
+ "required": [
8
+ "stac_extensions"
9
+ ],
10
+ "properties": {
11
+ "stac_extensions": {
12
+ "type": "array",
13
+ "allOf": [
14
+ {
15
+ "contains": {
16
+ "const": "https://stac-extensions.github.io/file/{{ file_extension_version }}/schema.json"
17
+ }
18
+ },
19
+ {
20
+ "contains": {
21
+ "const": "https://stac-extensions.github.io/{{ project_id|lower }}/{{ catalog_version }}/schema.json"
22
+ }
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ "oneOf": [
28
+ {
29
+ "$comment": "This is the schema for STAC Items.",
30
+ "type": "object",
31
+ "required": [
32
+ "collection"
33
+ ],
34
+ "properties": {
35
+ "type": {
36
+ "const": "Feature"
37
+ },
38
+ "id": {
39
+ "type": "string",
40
+ "pattern": "{{ drs_dataset_id_regex }}"
41
+ },
42
+ "collection": {
43
+ "const": "{{ project_id|upper }}"
44
+ },
45
+ "properties": {
46
+ "allOf": [
47
+ {
48
+ "$ref": "#/definitions/require_item_fields"
49
+ },
50
+ {
51
+ "$ref": "#/definitions/item_fields"
52
+ }
53
+ ]
54
+ },
55
+ "assets": {
56
+ "type": "object",
57
+ "additionalProperties": {
58
+ "allOf": [
59
+ {
60
+ "$ref": "#/definitions/require_asset_fields"
61
+ },
62
+ {
63
+ "$ref": "https://stac-extensions.github.io/file/{{ file_extension_version }}/schema.json#/definitions/fields"
64
+ },
65
+ {
66
+ "$ref": "#/definitions/asset_fields"
67
+ }
68
+ ]
69
+ }
70
+ }
71
+ }
72
+ },
73
+ {
74
+ "$comment": "This is the schema for STAC Collections, or more specifically only Collection Summaries in this case. By default, only checks the existence of the properties, but not the schema of the summaries.",
75
+ "type": "object",
76
+ "required": [
77
+ "type",
78
+ "summaries"
79
+ ],
80
+ "properties": {
81
+ "type": {
82
+ "const": "Collection"
83
+ },
84
+ "summaries": {
85
+ "$ref": "#/definitions/require_any"
86
+ }
87
+ }
88
+ }
89
+ ],
90
+ "definitions": {
91
+ "require_any": {
92
+ "$comment": "Only used for Collection summarizes.",
93
+ "type": "object",
94
+ "minProperties": 1
95
+ },
96
+ "require_item_fields": {
97
+ "$comment": "Please list all fields here so that we can force the existence of one of them in other parts of the schemas.",
98
+ "allOf": [
99
+ {
100
+ "required": [
101
+ "created"
102
+ ]
103
+ },
104
+ {
105
+ "required": [
106
+ "end_datetime"
107
+ ]
108
+ },
109
+ {
110
+ "required": [
111
+ "latest"
112
+ ]
113
+ },
114
+ {
115
+ "required": [
116
+ "retracted"
117
+ ]
118
+ },
119
+ {
120
+ "required": [
121
+ "size"
122
+ ]
123
+ },
124
+ {
125
+ "required": [
126
+ "start_datetime"
127
+ ]
128
+ },
129
+ {
130
+ "required": [
131
+ "title"
132
+ ]
133
+ },
134
+ {
135
+ "required": [
136
+ "updated"
137
+ ]
138
+ },
139
+ {% for dataset_property in catalog_dataset_properties|sort(attribute="field_name") %}
140
+ {% if dataset_property.is_required %}
141
+ {
142
+ "required": [
143
+ "{{ dataset_property.field_name }}"
144
+ ]
145
+ }
146
+ {% if not loop.last %},{% endif %}
147
+ {% endif %}
148
+ {% endfor %}
149
+ ]
150
+ },
151
+ "require_asset_fields": {
152
+ "$comment": "Please list all fields here so that we can force the existence of one of them in other parts of the schemas.",
153
+ "allOf": [
154
+ {
155
+ "required": [
156
+ "created"
157
+ ]
158
+ },
159
+ {
160
+ "required": [
161
+ "file:checksum"
162
+ ]
163
+ },
164
+ {
165
+ "required": [
166
+ "file:size"
167
+ ]
168
+ },
169
+ {
170
+ "required": [
171
+ "protocol"
172
+ ]
173
+ },
174
+ {
175
+ "required": [
176
+ "updated"
177
+ ]
178
+ },
179
+ {% for file_property in catalog_file_properties|sort(attribute="field_name") %}
180
+ {% if file_property.is_required %}
181
+ {
182
+ "required": [
183
+ "{{ file_property.field_name }}"
184
+ ]
185
+ }
186
+ {% if not loop.last %},{% endif %}
187
+ {% endif %}
188
+ {% endfor %}
189
+ ]
190
+ },
191
+ "asset_fields": {
192
+ "$comment": " Don't require fields here, do that above in the corresponding schema.",
193
+ "type": "object",
194
+ "properties": {
195
+ "protocol": {
196
+ "type": "string",
197
+ "enum": [
198
+ "http",
199
+ "https",
200
+ "globus",
201
+ "gridftp",
202
+ "kerchunk",
203
+ "netcdfsubset",
204
+ "opendap",
205
+ "wms",
206
+ "wps",
207
+ "s3"
208
+ ]
209
+ },
210
+ {% for file_property in catalog_file_properties|sort(attribute="field_name") %}
211
+ "{{ file_property.field_name }}": {
212
+ {% for key, value in file_property.field_value|dictsort(reverse=true) %}
213
+ "{{ key }}": {{ value|tojson }}
214
+ {% if not loop.last %},{% endif %}
215
+ {% endfor %}
216
+ }{% if not loop.last %},{% endif %}
217
+ {% endfor %}
218
+ }
219
+ },
220
+ "item_fields": {
221
+ "$comment": " Don't require fields here, do that above in the corresponding schema.",
222
+ "type": "object",
223
+ "properties": {
224
+ "latest": {
225
+ "type": "boolean"
226
+ },
227
+ "retracted": {
228
+ "type": "boolean"
229
+ },
230
+ "size": {
231
+ "type": "integer",
232
+ "minimum": 0
233
+ },
234
+ {% for dataset_property in catalog_dataset_properties|sort(attribute="field_name") %}
235
+ "{{ dataset_property.field_name }}": {
236
+ {% for key, value in dataset_property.field_value|dictsort(reverse=true) %}
237
+ "{{ key }}": {{ value|tojson }}
238
+ {% if not loop.last %},{% endif %}
239
+ {% endfor %}
240
+ }{% if not loop.last %},{% endif %}
241
+ {% endfor %}
242
+ },
243
+ "patternProperties": {
244
+ "^(?!{{ project_id|lower }}:)": {}
245
+ },
246
+ "additionalProperties": false
247
+ }
248
+ }
249
+ }
@@ -0,0 +1,214 @@
1
+ # CV Testing Application
2
+
3
+ This application provides comprehensive testing capabilities for project CVs and Universe CVs, allowing validation of repository structure, content, and esgvoc API integration.
4
+
5
+ ## Features
6
+
7
+ - **Multiple Testing Modes**: Repository structure validation, esgvoc API integration testing
8
+ - **Flexible Configuration**: Support for custom repositories, branches, and projects
9
+ - **Universe Branch Override**: Ability to test with custom Universe branches for comprehensive testing
10
+ - **CLI Integration**: Integrated with the main esgvoc CLI as `esgvoc test`
11
+ - **Rich Output**: Colored console output with progress indicators and detailed reporting
12
+
13
+ ## Available Projects
14
+
15
+ The application supports testing all configured CV projects:
16
+
17
+ - **cmip6**: CMIP6 controlled vocabularies
18
+ - **cmip6plus**: CMIP6Plus controlled vocabularies
19
+ - **input4mip**: Input4MIP controlled vocabularies
20
+ - **obs4mip**: Obs4MIP controlled vocabularies
21
+ - **cordex-cmip6**: CORDEX-CMIP6 controlled vocabularies
22
+
23
+ ## Usage
24
+
25
+ ### CLI Commands
26
+
27
+ ```bash
28
+ # List available projects
29
+ esgvoc test list-projects
30
+
31
+ # Configure esgvoc for testing a specific project
32
+ esgvoc test configure obs4mip
33
+ esgvoc test configure cmip6 --branch my-test-branch
34
+ esgvoc test configure cmip6 --universe-branch my-universe-branch
35
+ esgvoc test configure custom --repo https://github.com/me/cvs --branch main --universe-branch dev
36
+
37
+ # Test repository structure only
38
+ esgvoc test structure .
39
+ esgvoc test structure /path/to/cv/repo
40
+
41
+ # Test esgvoc API access only
42
+ esgvoc test api obs4mip .
43
+ esgvoc test api cmip6 /path/to/repo
44
+
45
+ # Run complete test suite
46
+ esgvoc test run obs4mip .
47
+ esgvoc test run cmip6 /path/to/repo --branch my-branch
48
+ esgvoc test run input4mip --branch esgvoc --universe-branch esgvoc_dev
49
+ esgvoc test run custom . --repo https://github.com/me/cvs --branch main --universe-branch dev
50
+
51
+ # Environment variable mode
52
+ export REPO_URL=https://github.com/me/obs4MIPs_CVs
53
+ export TEST_BRANCH=test-branch
54
+ export UNIVERSE_BRANCH=esgvoc_dev
55
+ esgvoc test env configure
56
+ esgvoc test env test
57
+ ```
58
+
59
+ ### Programmatic Usage
60
+
61
+ ```python
62
+ from esgvoc.apps.test_cv.cv_tester import CVTester
63
+
64
+ # Create tester instance
65
+ tester = CVTester()
66
+
67
+ try:
68
+ # Run complete test suite
69
+ success = tester.run_complete_test(
70
+ project_name="obs4mip",
71
+ repo_url="https://github.com/my-org/obs4MIPs_CVs", # optional
72
+ branch="test-branch", # optional
73
+ universe_branch="esgvoc_dev", # optional - custom universe branch
74
+ repo_path="."
75
+ )
76
+
77
+ if success:
78
+ print("✅ All tests passed!")
79
+ else:
80
+ print("❌ Some tests failed")
81
+
82
+ finally:
83
+ # Always cleanup
84
+ tester.cleanup()
85
+ ```
86
+
87
+ ### Individual Test Components
88
+
89
+ ```python
90
+ from esgvoc.apps.test_cv.cv_tester import CVTester
91
+
92
+ tester = CVTester()
93
+
94
+ try:
95
+ # 1. Configure esgvoc with custom universe branch
96
+ tester.configure_for_testing(
97
+ project_name="obs4mip",
98
+ repo_url="https://...",
99
+ branch="test",
100
+ universe_branch="esgvoc_dev" # Custom universe branch
101
+ )
102
+
103
+ # 2. Synchronize CVs
104
+ tester.synchronize_cvs()
105
+
106
+ # 3. Test repository structure
107
+ tester.test_repository_structure("/path/to/cv/repo")
108
+
109
+ # 4. Test esgvoc API access
110
+ tester.test_esgvoc_api_access("obs4mip", "/path/to/cv/repo")
111
+
112
+ finally:
113
+ tester.cleanup()
114
+ ```
115
+
116
+ ## Universe Branch Override
117
+
118
+ The application now supports testing with custom Universe branches, allowing comprehensive testing across different versions of the WCRP-universe repository:
119
+
120
+ ### CLI Usage
121
+ ```bash
122
+ # Test with custom universe branch
123
+ esgvoc test run input4mip --branch esgvoc --universe-branch esgvoc_dev
124
+
125
+ # Configure with custom universe branch
126
+ esgvoc test configure obs4mip --universe-branch development --sync
127
+
128
+ # Environment variable mode with universe branch
129
+ export UNIVERSE_BRANCH=esgvoc_dev
130
+ esgvoc test env test
131
+ ```
132
+
133
+ ### Programmatic Usage
134
+ ```python
135
+ # Test with custom universe branch
136
+ success = tester.run_complete_test(
137
+ project_name="input4mip",
138
+ branch="esgvoc", # Project branch
139
+ universe_branch="esgvoc_dev", # Universe branch
140
+ )
141
+
142
+ # Configure with custom universe branch
143
+ success = tester.configure_for_testing(
144
+ project_name="obs4mip",
145
+ universe_branch="development"
146
+ )
147
+ ```
148
+
149
+ ### Use Cases
150
+ - **Development Testing**: Test against development universe branches
151
+ - **Feature Validation**: Validate new universe features before merging
152
+ - **Regression Testing**: Ensure compatibility across universe versions
153
+ - **CI/CD Integration**: Test different universe branches in automated workflows
154
+
155
+ ## Test Components
156
+
157
+ ### Repository Structure Validation
158
+
159
+ Tests repository structure and file format compliance:
160
+
161
+ - **Collection Directories**: Validates presence of .jsonld context files
162
+ - **Element Files**: Validates JSON element file structure and required fields
163
+ - **Context Files**: Validates JSONLD context structure and required fields
164
+ - **Project Specs**: Validates project_specs.json references to collections
165
+
166
+ ### ESGVoc API Integration Testing
167
+
168
+ Tests that all repository content is accessible via esgvoc API:
169
+
170
+ - **Project Access**: Verifies project is queryable via esgvoc
171
+ - **Collection Access**: Validates all repository collections are accessible
172
+ - **Element Access**: Confirms all repository elements are queryable
173
+ - **API Functions**: Tests general esgvoc API functionality
174
+
175
+ ## Environment Variables
176
+
177
+ For CI/CD integration and automated testing:
178
+
179
+ - `REPO_URL`: Repository URL to test (required for `esgvoc test env` mode)
180
+ - `TEST_BRANCH`: Branch to test (required for `esgvoc test env` mode)
181
+ - `UNIVERSE_BRANCH`: Universe branch to test (optional)
182
+ - `PROJECT_NAME`: Project name (auto-detected if not provided)
183
+ - `ESGVOC_LIBRARY_BRANCH`: ESGVoc library branch (informational only)
184
+
185
+
186
+ ## Files
187
+
188
+ - `cv_tester.py`: Main CVTester class with all testing functionality
189
+ - `example_usage.py`: Usage examples and demonstrations
190
+ - `../cli/test_cv.py`: CLI integration module
191
+ - `README.md`: This documentation file
192
+
193
+ ## Error Handling
194
+
195
+ The application provides detailed error reporting:
196
+
197
+ - **Configuration Errors**: Issues with project setup or repository access
198
+ - **Structure Errors**: Problems with CV file format or organization
199
+ - **API Errors**: Issues with esgvoc integration or data access
200
+ - **Synchronization Errors**: Problems downloading or updating CVs
201
+
202
+ All errors include context and suggestions for resolution.
203
+
204
+ ## Testing Workflow
205
+
206
+ Recommended testing workflow for CV development:
207
+
208
+ 1. **Configure**: Set up esgvoc with your test repository/branch
209
+ 2. **Structure**: Validate repository structure and file formats
210
+ 3. **Sync**: Download/synchronize CVs with esgvoc
211
+ 4. **API**: Test that all content is accessible via esgvoc API
212
+ 5. **Cleanup**: Restore original esgvoc state
213
+
214
+ This ensures comprehensive validation of both the CV repository itself and its integration with the esgvoc system.