nmdc-schema 11.14.0__py3-none-any.whl → 11.14.0rc1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nmdc_schema
3
- Version: 11.14.0
3
+ Version: 11.14.0rc1
4
4
  Summary: Schema resources for the National Microbiome Data Collaborative (NMDC)
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -25,14 +25,13 @@ Requires-Dist: curies (>=0.9.0,<0.10.0)
25
25
  Requires-Dist: deprecated (>=1,<2)
26
26
  Requires-Dist: jsonasobj2 (>=1,<2)
27
27
  Requires-Dist: jsonschema (>=4,<5)
28
- Requires-Dist: linkml (>=1.9.6,<2.0.0)
29
- Requires-Dist: linkml-runtime (>=1.9.5,<2.0.0)
28
+ Requires-Dist: linkml (>=1.9.1,<2.0.0)
29
+ Requires-Dist: linkml-runtime (>=1.9.1,<2.0.0)
30
30
  Requires-Dist: pymongo (>=4.7.2,<5.0.0)
31
31
  Requires-Dist: python-dotenv
32
32
  Requires-Dist: pyyaml (>=6,<7)
33
33
  Requires-Dist: rdflib (>=6.2.0,<7.0.0)
34
34
  Requires-Dist: requests (>=2,<3)
35
- Requires-Dist: urllib3 (>=2.6.0)
36
35
  Project-URL: Documentation, https://microbiomedata.github.io/nmdc-schema/
37
36
  Project-URL: Homepage, https://microbiomedata.github.io/nmdc-schema/
38
37
  Project-URL: Repository, https://github.com/microbiomedata/nmdc-schema
@@ -42,7 +42,7 @@ nmdc_schema/migrators/migrator_from_10_6_0_to_10_7_0.py,sha256=-FduiWWIioYFQ2eST
42
42
  nmdc_schema/migrators/migrator_from_11_0_3_to_11_1_0.py,sha256=3hHXGts_sfre4KuIpGCUNyRMgI92_lXm_U2UStU-fdw,1184
43
43
  nmdc_schema/migrators/migrator_from_11_10_0_to_11_11_0.py,sha256=R4nUrhxRznukwKgkMQy8uuPzn-fE9AaQYNLLNsVOfTk,1354
44
44
  nmdc_schema/migrators/migrator_from_11_11_0_to_11_13_0.py,sha256=p0giuWeWOvxLe22T0QXNWxjzWWqgzJ1ZetpdVCz86IY,1354
45
- nmdc_schema/migrators/migrator_from_11_13_0_to_11_14_0.py,sha256=Y6WY3QGn9fVPh_hzyyC0UXX1U0nQNB624v48sJV_Gzo,1354
45
+ nmdc_schema/migrators/migrator_from_11_13_0_to_11_14_0.py,sha256=vUYKEMbfzBiNFlR7mEckwRcuM0cyUCfifom7Xn_kWMY,5002
46
46
  nmdc_schema/migrators/migrator_from_11_1_0_to_11_2_0.py,sha256=xGaG0oilg0Xvq-P6YOZea3EPQU8fyfcKo-KZl4BhgoM,1183
47
47
  nmdc_schema/migrators/migrator_from_11_3_0_to_11_4_0.py,sha256=XDRsT9KrKlZTOGHQekESZ2XSYD2UDydF1PWTRIeqOVE,1985
48
48
  nmdc_schema/migrators/migrator_from_11_4_0_to_11_5_0.py,sha256=uiFi5USF23lpuAbkDhVufnXxLsM-Aixrj4nw7GY-XO4,357
@@ -89,9 +89,6 @@ nmdc_schema/migrators/partials/migrator_from_11_11_0_to_11_13_0/__init__.py,sha2
89
89
  nmdc_schema/migrators/partials/migrator_from_11_11_0_to_11_13_0/migrator_from_11_11_0_to_11_13_0_part_1.py,sha256=ajPhHPDK1loTL7j_3hzBZo_EfT5gtoXlsNFmpDZCgPs,8668
90
90
  nmdc_schema/migrators/partials/migrator_from_11_11_0_to_11_13_0/migrator_from_11_11_0_to_11_13_0_part_2.py,sha256=sW5JhlO2DaGh9kvI9qWJQ85eYyUo9976sBurPdZ69Kk,4858
91
91
  nmdc_schema/migrators/partials/migrator_from_11_11_0_to_11_13_0/migrator_from_11_11_0_to_11_13_0_part_3.py,sha256=XKrq0jBLn6v4O96j045WkJsGubwP6ikLNyglEKH1_jE,1920
92
- nmdc_schema/migrators/partials/migrator_from_11_13_0_to_11_14_0/__init__.py,sha256=xXed_UcqkW7zWope_4ODapGf3xS_NKztCh6sK8GoUkc,999
93
- nmdc_schema/migrators/partials/migrator_from_11_13_0_to_11_14_0/migrator_from_11_13_0_to_11_14_0_part_1.py,sha256=7QuBZJlQE_emGgyQMfuiGBDDhdVVu57z6KQ8PStqyTs,5008
94
- nmdc_schema/migrators/partials/migrator_from_11_13_0_to_11_14_0/migrator_from_11_13_0_to_11_14_0_part_2.py,sha256=q5v3u6vFoIR12FbbI1Wji8guZ-D0RSxlOSTKzR0uNh0,1432
95
92
  nmdc_schema/migrators/partials/migrator_from_11_1_0_to_11_2_0/__init__.py,sha256=e-neqgmL6Zsy6h5PGmWPj9qIqrTm3yvNgo2l2i7Sduc,990
96
93
  nmdc_schema/migrators/partials/migrator_from_11_1_0_to_11_2_0/migrator_from_11_1_0_to_11_2_0_part_1.py,sha256=4nN_2iZqML84R9EgznIcj7FjIlRHSSM8XqLerUgMYbI,13230
97
94
  nmdc_schema/migrators/partials/migrator_from_11_1_0_to_11_2_0/migrator_from_11_1_0_to_11_2_0_part_2.py,sha256=HLGoX3KQZglHPODDO5FFHu2gjFjyBx8oGJ3D9PAkhNI,1628
@@ -111,18 +108,18 @@ nmdc_schema/migrators/partials/migrator_from_11_9_1_to_11_10_0/__init__.py,sha25
111
108
  nmdc_schema/migrators/partials/migrator_from_11_9_1_to_11_10_0/migrator_from_11_9_1_to_11_10_0_part_1.py,sha256=6MYmrB9yfJ3XFb2QabTcJeycK2tyVO3MtSItns2s9Zg,35421
112
109
  nmdc_schema/migrators/partials/migrator_from_11_9_1_to_11_10_0/migrator_from_11_9_1_to_11_10_0_part_2.py,sha256=wzard2sUTeRS7voVTfPt3_OtafTffnv0o0OyE1OBzA0,2987
113
110
  nmdc_schema/migrators/partials/migrator_from_11_9_1_to_11_10_0/migrator_from_11_9_1_to_11_10_0_part_3.py,sha256=crm2NEmn0xepEMKWHvCSkfX3G6hRn377f38rq24XlO8,3710
114
- nmdc_schema/nmdc-pydantic.py,sha256=-KFRbsDhJgamDFB25YrE-MDyJIYotUfumfyCtsVp16o,1407574
115
- nmdc_schema/nmdc.py,sha256=ekyLtGlyT7dMcZ-dwui7P_ZRc5NfM99xiZ3Attlk0rw,744344
116
- nmdc_schema/nmdc.schema.json,sha256=rwNxfZfGmJIP_uLwslNvX_xh64_sMpUWlsYGnVbisQ0,632806
111
+ nmdc_schema/nmdc-pydantic.py,sha256=KsCmfMksl-cw4Z117-q3cHhEc8Oo4xzGJXnKaUVoDfI,1449828
112
+ nmdc_schema/nmdc.py,sha256=ZqLvE_GJFJXJHvRlEW_XX716RCW5Yy6BRps-RQErro4,737461
113
+ nmdc_schema/nmdc.schema.json,sha256=JsUcoZvBYBU94OqjRp9tIgNsfFblEEy5-VAoUki65Ho,630048
117
114
  nmdc_schema/nmdc_data.py,sha256=_wNKi5NDxuvvRsJEim2ialX7VJkDBJLRpiTOPpFHBm8,9608
118
- nmdc_schema/nmdc_materialized_patterns.json,sha256=4BxPDYqUiYMKvJfTMIXeM8fkcnv5KDEX75qlRFe518g,915842
119
- nmdc_schema/nmdc_materialized_patterns.schema.json,sha256=UYOWffYZaiUfVdCV0GXRnN2o2EIeYFVe8aZ2IdPv46A,642131
120
- nmdc_schema/nmdc_materialized_patterns.yaml,sha256=rMUjokG3a2WfhGS4YWonbIc4Rv1r9szX9_7D2KxINcc,711525
115
+ nmdc_schema/nmdc_materialized_patterns.json,sha256=zmYoq8BL4PdUCVn4dQdN7pM11gdFFNIvBw2Ih5RKkpY,912372
116
+ nmdc_schema/nmdc_materialized_patterns.schema.json,sha256=1SxFfOBnB9fuyfcihHikDbs2pd3X7Oa3bROai1ZmHUg,639373
117
+ nmdc_schema/nmdc_materialized_patterns.yaml,sha256=tIyM9hg9PLfTe2O3XFWL3V8f6su0wLT_8eKN8H0QNJ4,708950
121
118
  nmdc_schema/nmdc_schema_validation_plugin.py,sha256=rjtn1tYhngGyc1AV8vcT8BJ9a_MmHbcK3hRUf9dzPtA,4799
122
119
  nmdc_schema/nmdc_version.py,sha256=DsfEKnmN3LHR831WWELxyfZY6rnP9U8tfygamkrsaHY,2305
123
120
  nmdc_schema/validate_nmdc_json.py,sha256=PVJV2O1qQXMi206HaUKqRNLiLc164OpNYKPURSKN8_E,3148
124
- nmdc_schema-11.14.0.dist-info/METADATA,sha256=Qqe_PIlPIQt1vy2rup3JD0DixWGnpe7iMVqsgwyCHns,5883
125
- nmdc_schema-11.14.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
126
- nmdc_schema-11.14.0.dist-info/entry_points.txt,sha256=ioyD5P6op5Zy68bqg5MafLAryb73rfzyx8YXKItroC8,1531
127
- nmdc_schema-11.14.0.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
128
- nmdc_schema-11.14.0.dist-info/RECORD,,
121
+ nmdc_schema-11.14.0rc1.dist-info/METADATA,sha256=t4DH8Zj0l7cEMHXQikzWicxyNiyhEL3wSPI2JlSdeW0,5853
122
+ nmdc_schema-11.14.0rc1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
123
+ nmdc_schema-11.14.0rc1.dist-info/entry_points.txt,sha256=-UOl7vTEjS6eaJreIu_UenULpuKAYz8JiLeuKbEqPB8,2079
124
+ nmdc_schema-11.14.0rc1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
125
+ nmdc_schema-11.14.0rc1.dist-info/RECORD,,
@@ -22,4 +22,12 @@ schema-pattern-linting=src.scripts.schema_pattern_linting:main
22
22
  schema-view-relation-graph=src.scripts.schema_view_relation_graph:cli
23
23
  scrutinize-elements=src.scripts.scrutinize_elements:process_schema_elements
24
24
  slot-range-type-reporter=src.scripts.slot_range_type_reporter:cli
25
+ units-mongodb-analyze=units.scripts.mongodb_analyze_units:main
26
+ units-schema-convert=units.scripts.schema_convert_to_ucum:main
27
+ units-schema-extract=units.scripts.schema_extract_preferred_units:main
28
+ units-schema-extract-slot-unit-pairs=units.scripts.schema_expand_storage_units:main
29
+ units-schema-generate=units.scripts.schema_generate_yq_commands:main
30
+ units-testdata-check=units.scripts.testdata_check_has_unit:main
31
+ units-testdata-extract=units.scripts.testdata_extract_quantity_values:main
32
+ units-ucum-validate=units.scripts.ucum_validate_units:main
25
33
 
@@ -1,28 +0,0 @@
1
- from typing import List, Type
2
-
3
- from nmdc_schema.migrators.migrator_base import MigratorBase
4
- from nmdc_schema.migrators.partials.migrator_from_11_13_0_to_11_14_0 import (
5
- migrator_from_11_13_0_to_11_14_0_part_1,
6
- migrator_from_11_13_0_to_11_14_0_part_2
7
- )
8
-
9
-
10
- def get_migrator_classes() -> List[Type[MigratorBase]]:
11
- r"""
12
- Returns a list of migrator classes in the order in which they (i.e. their `upgrade` methods)
13
- were designed to be run.
14
-
15
- >>> migrator_classes = get_migrator_classes()
16
- >>> type(migrator_classes) is list and len(migrator_classes) > 0 # the function returns a list
17
- True
18
- >>> from inspect import isclass
19
- >>> all(isclass(c) for c in migrator_classes) # each list item is a class
20
- True
21
- >>> all(callable(getattr(c, "upgrade")) for c in migrator_classes) # each class has an `upgrade` method
22
- True
23
- """
24
-
25
- return [
26
- migrator_from_11_13_0_to_11_14_0_part_1.Migrator,
27
- migrator_from_11_13_0_to_11_14_0_part_2.Migrator
28
- ]
@@ -1,113 +0,0 @@
1
- from linkml.validator import Validator
2
-
3
- from nmdc_schema.migrators.migrator_base import MigratorBase
4
- import sys
5
- from pathlib import Path
6
- from nmdc_schema.migrators.helpers import create_schema_view, get_classes_with_slots_by_range, \
7
- get_database_collections_for_class
8
- from nmdc_schema import NmdcSchemaValidationPlugin
9
-
10
- project_root = Path(__file__).parent.parent.parent
11
- sys.path.insert(0, str(project_root))
12
-
13
-
14
- class Migrator(MigratorBase):
15
- r"""A check-only migrator that raises an exception if any QuantityValue's has_unit slot
16
- is not valid against the slot's storage_unit or UnitEnum constraints."""
17
-
18
- _from_version = '11.13.0'
19
- _to_version = '11.14.0_part_1'
20
-
21
- def __init__(self, *args, **kwargs):
22
- super().__init__(*args, **kwargs)
23
-
24
- self.schema_view = create_schema_view()
25
- self.validator = Validator(
26
- self.schema_view.schema,
27
- # This is intentionally *only* using the NMDC plugin, because this migrator is *only*
28
- # concerned with validating the QuantityValue-related constraints that the plugin
29
- # implements.
30
- validation_plugins=[
31
- NmdcSchemaValidationPlugin()
32
- ]
33
- )
34
-
35
- def upgrade(self, commit_changes: bool = False) -> None:
36
- r'''
37
- Migrates the database from conforming to the original schema, to conforming to the new schema.
38
- '''
39
-
40
- # Get the schema classes which have slots with range QuantityValue
41
- classes_with_qv_slots = get_classes_with_slots_by_range(self.schema_view, 'QuantityValue')
42
-
43
- # Get the Database collection names that can hold these classes
44
- eligible_collection_names = set()
45
- for class_name in classes_with_qv_slots.keys():
46
- collection_names = get_database_collections_for_class(self.schema_view, class_name)
47
- eligible_collection_names.update(collection_names)
48
-
49
- # Apply migrator through collections
50
- self.logger.info("Checking QuantityValue units against UnitEnum and storage_units constraints")
51
- for collection_name in eligible_collection_names:
52
- self.logger.info(f" Checking collection '{collection_name}'")
53
- self.adapter.do_for_each_document(collection_name, self.confirm_units_fit_unitenum_and_storage_units)
54
-
55
- def confirm_units_fit_unitenum_and_storage_units(self, document: dict) -> None:
56
- r'''
57
- Raise an exception if the QuantityValue's has_unit slot is not valid against slot's storage_unit or UnitEnum constraints.
58
-
59
- >>> m = Migrator()
60
-
61
- # Test: valid QuantityValue with proper units in biosample
62
- >>> valid_biosample = {
63
- ... "id": "test1",
64
- ... "type": "nmdc:Biosample",
65
- ... "bulk_elect_conductivity": {
66
- ... "type": "nmdc:QuantityValue",
67
- ... "has_unit": "mS/cm",
68
- ... "has_numeric_value": 25.0
69
- ... }
70
- ... }
71
- >>> m.confirm_units_fit_unitenum_and_storage_units(valid_biosample) # Should not raise
72
-
73
- # Test: unit not allowed for bulk_elect_conductivity's storage_units
74
- >>> invalid_biosample_storage = {
75
- ... "id": "test2",
76
- ... "type": "nmdc:Biosample",
77
- ... "bulk_elect_conductivity": {
78
- ... "type": "nmdc:QuantityValue",
79
- ... "has_unit": "Cel",
80
- ... "has_numeric_value": 25.0
81
- ... }
82
- ... }
83
- >>> m.confirm_units_fit_unitenum_and_storage_units(invalid_biosample_storage)
84
- Traceback (most recent call last):
85
- ...
86
- ValueError: In test2:
87
- QuantityValue at /bulk_elect_conductivity has unit 'Cel' which is not allowed for slot 'bulk_elect_conductivity' (allowed: mS/cm)
88
-
89
- # Test: unit not allowed for substances_volume's storage_units
90
- >>> invalid_chem_storage = {
91
- ... "id": "test3",
92
- ... "type": "nmdc:ChemicalConversionProcess",
93
- ... "substances_volume": {
94
- ... "type": "nmdc:QuantityValue",
95
- ... "has_unit": "J/K", # Wrong unit type for substances_volume
96
- ... "has_numeric_value": 25.0
97
- ... }
98
- ... }
99
- >>> m.confirm_units_fit_unitenum_and_storage_units(invalid_chem_storage)
100
- Traceback (most recent call last):
101
- ...
102
- ValueError: In test3:
103
- QuantityValue at /substances_volume has unit 'J/K' which is not allowed for slot 'substances_volume' (allowed: mL)
104
- '''
105
-
106
- document_id = document.get('id', '<unknown id>')
107
- document_type = document.get('type')
108
- if not document_type:
109
- raise ValueError(f"Unable to infer target_class for document with id '{document_id}'")
110
- target_class = document_type.replace('nmdc:', '')
111
- report = self.validator.validate(document, target_class)
112
- if report.results:
113
- raise ValueError(f"In {document_id}:\n" + "\n".join(" " + result.message for result in report.results))
@@ -1,40 +0,0 @@
1
- from nmdc_schema.migrators.migrator_base import MigratorBase
2
-
3
-
4
- class Migrator(MigratorBase):
5
- r"""
6
- Migrates a database between two schemas.
7
- """
8
-
9
- _from_version = "11.14.0_part_1"
10
- _to_version = "11.14.0_part_2"
11
-
12
- def upgrade(self, commit_changes: bool = False) -> None:
13
- r"""
14
- Migrates the database from conforming to the original schema, to conforming to the new schema.
15
- """
16
- self.adapter.do_for_each_document("processed_sample_set", self.confirm_empty)
17
-
18
- def confirm_empty(self, processedsample: dict) -> None:
19
- r"""
20
- If a processedsample has a value for 'biomaterial_purity' raise an exception.
21
-
22
- >>> m = Migrator()
23
-
24
- # Test: processed sample has biomaterial_purity value
25
- >>> m.confirm_empty({"id": 1, "type": "nmdc:ProcessedSample", "biomaterial_purity": ["Test_Value"]})
26
- Traceback (most recent call last):
27
- ...
28
- ValueError: Biosample 1 'biomaterial_purity' values include: ['Test_Value']
29
-
30
- # Test: valid processedsample
31
- >>> m.confirm_empty({"id": 3, "type": "nmdc:ProcessedSample"}) is None
32
- True
33
- """
34
- bp_values = processedsample.get("biomaterial_purity", [])
35
- biosample_id = processedsample.get("id")
36
-
37
- if len(bp_values)>0:
38
- raise ValueError(
39
- f"Biosample {biosample_id} 'biomaterial_purity' values include: {bp_values}"
40
- )