Skip to content

Commit 6108627

Browse files
Merge pull request #48 from AustralianBioCommons/feature-add-program-template
Add program template generation and update CLI logic
2 parents ab5710d + 6a28a88 commit 6108627

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

src/gen3schemadev/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
generate_setting_template,
1111
generate_terms_template,
1212
generate_core_metadata_template,
13-
generate_project_template
13+
generate_project_template,
14+
generate_program_template
1415
)
1516
from gen3schemadev.utils import write_yaml, load_yaml, bundle_yamls, write_json, resolve_schema, read_json
1617
from gen3schemadev.schema.input_schema import DataModel
@@ -184,7 +185,10 @@ def main():
184185
write_yaml(setting_dict, f"{args.output}/_settings.yaml")
185186
write_yaml(generate_terms_template(), f"{args.output}/_terms.yaml")
186187
write_yaml(generate_core_metadata_template(), f"{args.output}/core_metadata_collection.yaml")
187-
write_yaml(generate_project_template(), f"{args.output}/project.yaml")
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")
188192

189193
print("Schema generation process complete.")
190194

src/gen3schemadev/schema/gen3_template.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,7 @@ def generate_core_metadata_template():
7474
return read_template_yaml('core_metadata_collection.yaml')
7575

7676
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')
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

tests/input_example.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ nodes:
6161

6262

6363
links:
64+
65+
- parent: program # program is the root and is auto generated when you use the `gen3schemadev generate` command
66+
multiplicity: one_to_many
67+
child: project
68+
6469
- parent: project
6570
multiplicity: one_to_many
6671
child: sample

tests/test_converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ def test_construct_prop_project(fixture_input_yaml_pass):
467467
"description": {
468468
"type": "string",
469469
"description": "Project containing synthetic data"
470-
}
470+
},
471+
"programs": {'$ref': '_definitions.yaml#/to_one'},
471472
}
472473
assert result == expected
473474

tests/test_gen3_template.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@ def test_generate_project_template_reads_project_yaml():
109109
result = generate_project_template()
110110
assert isinstance(result, dict)
111111
assert "id" in result
112-
assert result.get("id") == "project"
112+
assert result.get("id") == "project"
113+
114+
def test_generate_program_template_reads_program_yaml():
115+
result = generate_program_template()
116+
assert isinstance(result, dict)
117+
assert "id" in result
118+
assert result.get("id") == "program"

0 commit comments

Comments
 (0)