Gen3SchemaDev 2.1.0__tar.gz → 2.2.0__tar.gz
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.
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/PKG-INFO +1 -1
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/pyproject.toml +1 -1
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/cli.py +6 -2
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/converter.py +26 -7
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/gen3_template.py +4 -1
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/gen3_metaschema.yml +2 -3
- gen3schemadev-2.2.0/src/gen3schemadev/schema/schema_templates/program.yaml +34 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/validators/rule_validator.py +4 -2
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/LICENSE +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/README.md +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/__init__.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/ddvis.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/__init__.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/input_schema.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/_definitions.yaml +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/_settings.yaml +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/_terms.yaml +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/core_metadata_collection.yaml +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/project.yaml +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/utils.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/validators/input_validator.py +0 -0
- {gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/validators/metaschema_validator.py +0 -0
|
@@ -10,7 +10,8 @@ from gen3schemadev.schema.gen3_template import (
|
|
|
10
10
|
generate_setting_template,
|
|
11
11
|
generate_terms_template,
|
|
12
12
|
generate_core_metadata_template,
|
|
13
|
-
generate_project_template
|
|
13
|
+
generate_project_template,
|
|
14
|
+
generate_program_template
|
|
14
15
|
)
|
|
15
16
|
from gen3schemadev.utils import write_yaml, load_yaml, bundle_yamls, write_json, resolve_schema, read_json
|
|
16
17
|
from gen3schemadev.schema.input_schema import DataModel
|
|
@@ -184,7 +185,10 @@ def main():
|
|
|
184
185
|
write_yaml(setting_dict, f"{args.output}/_settings.yaml")
|
|
185
186
|
write_yaml(generate_terms_template(), f"{args.output}/_terms.yaml")
|
|
186
187
|
write_yaml(generate_core_metadata_template(), f"{args.output}/core_metadata_collection.yaml")
|
|
187
|
-
|
|
188
|
+
if 'project' not in node_names:
|
|
189
|
+
write_yaml(generate_project_template(), f"{args.output}/project.yaml")
|
|
190
|
+
if 'program' not in node_names:
|
|
191
|
+
write_yaml(generate_program_template(), f"{args.output}/program.yaml")
|
|
188
192
|
|
|
189
193
|
print("Schema generation process complete.")
|
|
190
194
|
|
|
@@ -173,7 +173,7 @@ def get_node_links(node: str, data: DataSourceProtocol) -> list[dict]:
|
|
|
173
173
|
return node_links
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
def create_core_metadata_link(child_name: str) -> dict:
|
|
176
|
+
def create_core_metadata_link(child_name: str, required: bool = False) -> dict:
|
|
177
177
|
"""
|
|
178
178
|
Create a link dictionary for core metadata collections.
|
|
179
179
|
|
|
@@ -188,14 +188,33 @@ def create_core_metadata_link(child_name: str) -> dict:
|
|
|
188
188
|
link_obj = LinkObj(
|
|
189
189
|
name=link_suffix("core_metadata_collection"),
|
|
190
190
|
backref=link_suffix(child_name),
|
|
191
|
-
label=
|
|
191
|
+
label="part_of",
|
|
192
192
|
target_type="core_metadata_collection",
|
|
193
193
|
multiplicity="one_to_one",
|
|
194
|
-
required=
|
|
194
|
+
required=required
|
|
195
195
|
)
|
|
196
196
|
return link_obj.to_dict()
|
|
197
197
|
|
|
198
198
|
|
|
199
|
+
def flip_multiplicity(multiplicity: str) -> str:
|
|
200
|
+
"""
|
|
201
|
+
Flip the multiplicity of a link.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
multiplicity: The current multiplicity of the link.
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
The flipped multiplicity.
|
|
208
|
+
"""
|
|
209
|
+
if multiplicity == "one_to_one" or multiplicity == "many_to_many":
|
|
210
|
+
return multiplicity
|
|
211
|
+
elif multiplicity == "one_to_many":
|
|
212
|
+
return "many_to_one"
|
|
213
|
+
elif multiplicity == "many_to_one":
|
|
214
|
+
return "one_to_many"
|
|
215
|
+
else:
|
|
216
|
+
raise ValueError(f"Invalid multiplicity: {multiplicity}")
|
|
217
|
+
|
|
199
218
|
def convert_node_links(links: list[dict], required: bool = True) -> list[dict]:
|
|
200
219
|
"""
|
|
201
220
|
Convert a list of link dictionaries into the Gen3 schema 'links' format.
|
|
@@ -212,9 +231,9 @@ def convert_node_links(links: list[dict], required: bool = True) -> list[dict]:
|
|
|
212
231
|
link_obj = LinkObj(
|
|
213
232
|
name=link_suffix(link['parent']),
|
|
214
233
|
backref=link_suffix(link['child']),
|
|
215
|
-
label=
|
|
234
|
+
label="part_of",
|
|
216
235
|
target_type=link['parent'],
|
|
217
|
-
multiplicity=link['multiplicity'],
|
|
236
|
+
multiplicity=flip_multiplicity(link['multiplicity']),
|
|
218
237
|
required=required
|
|
219
238
|
)
|
|
220
239
|
link_list.append(link_obj.to_dict())
|
|
@@ -233,7 +252,7 @@ def add_core_metadata_link(links: list[dict], child_name: str) -> list[dict]:
|
|
|
233
252
|
Returns:
|
|
234
253
|
Updated list of link dictionaries including core metadata link.
|
|
235
254
|
"""
|
|
236
|
-
core_link = create_core_metadata_link(child_name)
|
|
255
|
+
core_link = create_core_metadata_link(child_name, required=False)
|
|
237
256
|
return links + [core_link]
|
|
238
257
|
|
|
239
258
|
|
|
@@ -539,7 +558,7 @@ def construct_props(node_name: str, data: DataSourceProtocol) -> dict:
|
|
|
539
558
|
|
|
540
559
|
# Add link properties
|
|
541
560
|
for link in links:
|
|
542
|
-
link_prop = create_link_prop(link['parent'], link['multiplicity'])
|
|
561
|
+
link_prop = create_link_prop(link['parent'], flip_multiplicity(link['multiplicity']))
|
|
543
562
|
props_dict.update(link_prop)
|
|
544
563
|
|
|
545
564
|
# if it's an Enum, add the enum values
|
|
@@ -74,4 +74,7 @@ def generate_core_metadata_template():
|
|
|
74
74
|
return read_template_yaml('core_metadata_collection.yaml')
|
|
75
75
|
|
|
76
76
|
def get_metaschema():
|
|
77
|
-
return read_template_yaml('gen3_metaschema.yml')
|
|
77
|
+
return read_template_yaml('gen3_metaschema.yml')
|
|
78
|
+
|
|
79
|
+
def generate_program_template():
|
|
80
|
+
return read_template_yaml('program.yaml')
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
$schema: http://json-schema.org/draft-04/schema#
|
|
2
|
+
id: program
|
|
3
|
+
title: Program
|
|
4
|
+
type: object
|
|
5
|
+
category: administrative
|
|
6
|
+
program: '*'
|
|
7
|
+
project: '*'
|
|
8
|
+
description: 'A broad framework of goals to be achieved. (NCIt C52647)
|
|
9
|
+
|
|
10
|
+
'
|
|
11
|
+
additionalProperties: false
|
|
12
|
+
submittable: false
|
|
13
|
+
validators: null
|
|
14
|
+
systemProperties:
|
|
15
|
+
- id
|
|
16
|
+
required:
|
|
17
|
+
- name
|
|
18
|
+
- dbgap_accession_number
|
|
19
|
+
uniqueKeys:
|
|
20
|
+
- - id
|
|
21
|
+
- - name
|
|
22
|
+
links: []
|
|
23
|
+
properties:
|
|
24
|
+
type:
|
|
25
|
+
type: string
|
|
26
|
+
id:
|
|
27
|
+
$ref: _definitions.yaml#/UUID
|
|
28
|
+
systemAlias: node_id
|
|
29
|
+
name:
|
|
30
|
+
type: string
|
|
31
|
+
description: Full name/title of the program.
|
|
32
|
+
dbgap_accession_number:
|
|
33
|
+
type: string
|
|
34
|
+
description: The dbgap accession number provided for the program.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# validates gen3 bundled jsonschema (.json) by testing gen3 specific business rules
|
|
2
2
|
import logging
|
|
3
|
+
from gen3schemadev.converter import link_suffix
|
|
3
4
|
|
|
4
5
|
logger = logging.getLogger(__name__)
|
|
5
6
|
|
|
@@ -44,7 +45,7 @@ class RuleValidator:
|
|
|
44
45
|
links = self._get_links()
|
|
45
46
|
logger.debug(f"Got links for data_file: {links}")
|
|
46
47
|
for link in links:
|
|
47
|
-
if link.get("name") == "core_metadata_collection":
|
|
48
|
+
if link.get("name") == link_suffix("core_metadata_collection"):
|
|
48
49
|
logger.debug(
|
|
49
50
|
f"Found core_metadata_collection link for data_file node (id: {schema_id})."
|
|
50
51
|
)
|
|
@@ -54,7 +55,7 @@ class RuleValidator:
|
|
|
54
55
|
)
|
|
55
56
|
raise ValueError(
|
|
56
57
|
f"Schema '{schema_id}' with category 'data_file' must include a link with "
|
|
57
|
-
f"'name': '
|
|
58
|
+
f"'name': 'core_metadata_collections'. Please add this link to the 'links' section."
|
|
58
59
|
)
|
|
59
60
|
return False
|
|
60
61
|
except Exception as ex:
|
|
@@ -118,6 +119,7 @@ class RuleValidator:
|
|
|
118
119
|
"updated_datetime",
|
|
119
120
|
"file_state",
|
|
120
121
|
"error_type",
|
|
122
|
+
"label"
|
|
121
123
|
]
|
|
122
124
|
logger.debug(f"System properties: {system_props}")
|
|
123
125
|
return system_props
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/_settings.yaml
RENAMED
|
File without changes
|
{gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/_terms.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/schema/schema_templates/project.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3schemadev-2.1.0 → gen3schemadev-2.2.0}/src/gen3schemadev/validators/metaschema_validator.py
RENAMED
|
File without changes
|