Gen3SchemaDev 2.3.4__tar.gz → 2.3.6__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.
Files changed (22) hide show
  1. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/PKG-INFO +1 -1
  2. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/pyproject.toml +1 -1
  3. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/converter.py +17 -9
  4. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/validators/rule_validator.py +17 -0
  5. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/LICENSE +0 -0
  6. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/README.md +0 -0
  7. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/__init__.py +0 -0
  8. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/cli.py +0 -0
  9. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/ddvis.py +0 -0
  10. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/__init__.py +0 -0
  11. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/gen3_template.py +0 -0
  12. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/input_schema.py +0 -0
  13. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/_definitions.yaml +0 -0
  14. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/_settings.yaml +0 -0
  15. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/_terms.yaml +0 -0
  16. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/core_metadata_collection.yaml +0 -0
  17. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/gen3_metaschema.yml +0 -0
  18. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/program.yaml +0 -0
  19. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/schema/schema_templates/project.yaml +0 -0
  20. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/utils.py +0 -0
  21. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/validators/input_validator.py +0 -0
  22. {gen3schemadev-2.3.4 → gen3schemadev-2.3.6}/src/gen3schemadev/validators/metaschema_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Gen3SchemaDev
3
- Version: 2.3.4
3
+ Version: 2.3.6
4
4
  Summary: Tool for data modelling in Gen3
5
5
  License: Apache 2.0
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Gen3SchemaDev"
3
- version = "2.3.4"
3
+ version = "2.3.6"
4
4
  description = "Tool for data modelling in Gen3"
5
5
  authors = [
6
6
  {name = "JoshuaHarris391",email = "harjo391@gmail.com"}
@@ -307,6 +307,10 @@ def create_link_prop(target_node: str, multiplicity: str) -> dict:
307
307
  """
308
308
  Create a property dictionary for a link to another node.
309
309
 
310
+ Links targeting 'project' use the special 'to_one_project' / 'to_many_project'
311
+ definitions because the project foreign key is identified by 'id' or 'code'
312
+ (foreign_key_project), not the standard 'id' or 'submitter_id' (foreign_key).
313
+
310
314
  Args:
311
315
  target_node: The name of the target node.
312
316
  multiplicity: The multiplicity of the link (e.g., 'one_to_one', 'one_to_many').
@@ -314,9 +318,14 @@ def create_link_prop(target_node: str, multiplicity: str) -> dict:
314
318
  Returns:
315
319
  A dictionary representing the link property for the schema.
316
320
  """
321
+ formatted = format_multiplicity(multiplicity)
322
+ if target_node == "project":
323
+ ref = f"_definitions.yaml#/{formatted}_project"
324
+ else:
325
+ ref = f"_definitions.yaml#/{formatted}"
317
326
  link_prop = {
318
327
  link_suffix(target_node): {
319
- "$ref": f"_definitions.yaml#/{format_multiplicity(multiplicity)}"
328
+ "$ref": ref
320
329
  }
321
330
  }
322
331
  return link_prop
@@ -623,21 +632,20 @@ def construct_props(node_name: str, data: DataSourceProtocol) -> dict:
623
632
 
624
633
  # if it's an Enum, add the enum values
625
634
  if category == "data_file":
626
- props_dict['core_metadata_collections'] = {"$ref": "_definitions.yaml#/to_one"}
627
635
  props_dict['$ref'] = "_definitions.yaml#/data_file_properties"
628
-
629
- props_dict['data_category'] = {
636
+ props_dict.setdefault('core_metadata_collections', {"$ref": "_definitions.yaml#/to_one"})
637
+ props_dict.setdefault('data_category', {
630
638
  "description": "Broad categorization of the contents of the data file.",
631
639
  "enum": ['data_category_1', 'data_category_2', 'data_category_3']
632
- }
633
- props_dict['data_format'] = {
640
+ })
641
+ props_dict.setdefault('data_format', {
634
642
  "description": "The format of the data in this data file",
635
643
  "enum": ['data_format_1', 'data_format_2', 'data_format_3']
636
- }
637
- props_dict['data_type'] = {
644
+ })
645
+ props_dict.setdefault('data_type', {
638
646
  "description": "The type of data in this data file",
639
647
  "enum": ['data_type_1', 'data_type_2', 'data_type_3']
640
- }
648
+ })
641
649
 
642
650
  return props_dict
643
651
 
@@ -17,6 +17,7 @@ class RuleValidator:
17
17
  self.type_array_needs_items()
18
18
  self.core_metadata_required_link()
19
19
  self.data_file_props_need_data_props()
20
+ self.project_must_require_code()
20
21
 
21
22
  def _get_links(self):
22
23
  links = self.schema.get("links", [])
@@ -239,6 +240,22 @@ class RuleValidator:
239
240
  return True
240
241
 
241
242
 
243
+ def project_must_require_code(self):
244
+ """If the schema is for the project node (id: project),
245
+ then 'code' must be in the required list. Gen3 uses 'code'
246
+ as the unique project identifier.
247
+ """
248
+ if self.schema.get('id', '') != 'project':
249
+ return True
250
+
251
+ required = self.schema.get('required', [])
252
+ if 'code' not in required:
253
+ raise ValueError(
254
+ f"Schema 'project' must include 'code' in the 'required' list. "
255
+ f"Please add 'code' to the 'required' section."
256
+ )
257
+ return True
258
+
242
259
  def core_metadata_required_link(self):
243
260
  """Core metadata collection schema needs at least one required link
244
261
  """
File without changes
File without changes