Skip to content

Commit 588156e

Browse files
authored
Update to BcoValidator.load_schema (#341)
Updated the function to check locally for the most used schemas. Improves testing and speed in BCO validation. Changes to be committed: modified: biocompute/services.py renamed: config/IEEE/2791object.json -> config/schemas/2791object.json new file: config/schemas/dataset_extension.json renamed: config/IEEE/description_domain.json -> config/schemas/description_domain.json renamed: config/IEEE/error_domain.json -> config/schemas/error_domain.json renamed: config/IEEE/execution_domain.json -> config/schemas/execution_domain.json new file: config/schemas/fhir_extension.json new file: config/schemas/galaxy_extension.json renamed: config/IEEE/io_domain.json -> config/schemas/io_domain.json new file: config/schemas/license_extension.json renamed: config/IEEE/parametric_domain.json -> config/schemas/parametric_domain.json renamed: config/IEEE/provenance_domain.json -> config/schemas/provenance_domain.json new file: config/schemas/scm_extension.json renamed: config/IEEE/usability_domain.json -> config/schemas/usability_domain.json
1 parent 5c5c1f7 commit 588156e

14 files changed

+265
-6
lines changed

biocompute/services.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ def load_schema(schema_uri):
5050
Returns:
5151
- dict: The loaded JSON schema.
5252
"""
53-
54-
if schema_uri == \
55-
"https://w3id.org/ieee/ieee-2791-schema/2791object.json":
56-
return jsonref.load_uri(
57-
f"file://{BASE_DIR}/config/IEEE/2791object.json"
58-
)
53+
schema_mapping = {
54+
"https://w3id.org/ieee/ieee-2791-schema/2791object.json": f"{BASE_DIR}/config/schemas/2791object.json",
55+
"https://raw.githubusercontent.com/biocompute-objects/extension_domain/1.1.0/dataset_extension.json": f"{BASE_DIR}/config/schemas/dataset_extension.json",
56+
"https://raw.githubusercontent.com/biocompute-objects/extension_domain/1.1.0/fhir_extension.json": f"{BASE_DIR}/config/schemas/fhir_extension.json",
57+
"https://raw.githubusercontent.com/biocompute-objects/extension_domain/1.1.0/galaxy_extension.json": f"{BASE_DIR}/config/schemas/galaxy_extension.json",
58+
"https://raw.githubusercontent.com/biocompute-objects/extension_domain/1.1.0/license_extension.json": f"{BASE_DIR}/config/schemas/license_extension.json",
59+
"https://raw.githubusercontent.com/biocompute-objects/extension_domain/1.1.0/scm_extension.json": f"{BASE_DIR}/config/schemas/scm_extension.json"
60+
}
61+
if schema_uri in schema_mapping:
62+
return jsonref.load_uri(f"file://{schema_mapping[schema_uri]}")
5963
try:
6064
return jsonref.load_uri(schema_uri)
6165
except (JSONDecodeError, TypeError, RequestsConnectionError) as e:
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "http://www.w3id.org/biocompute/extension_domain/1.1.0/dataset/dataset_extension.json",
4+
"title": "dataset_extension",
5+
"type": "object",
6+
"description": "The external references extension to list additional licenses and dataset catagories for a dataset BCO (dsBCO).",
7+
"required": ["dataset_extension", "extension_schema"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"dataset_extension": {
11+
"type": "object",
12+
"additionalProperties": false,
13+
"required": ["dataset_categories"],
14+
"properties": {
15+
"additional_license": {
16+
"type": "object",
17+
"description": "The additional license property contains the details about the licenses applied to the dataset and the script or tool/software used to process the given dataset.",
18+
"additionalProperties": false,
19+
"properties": {
20+
"data_license": {
21+
"title": "data_license",
22+
"type": "string",
23+
"description": "The license applied to the data or the dataset by the author",
24+
"examples": ["https://creativecommons.org/licenses/by/4.0/"]
25+
},
26+
"script_license": {
27+
"title": "script_license",
28+
"type": "string",
29+
"description": "The license applied to the computational script or the tool/software developed to process (parse, QC, align) the input dataset for a final output dataset.",
30+
"examples": ["https://www.gnu.org/licenses/gpl-3.0.en.html"]
31+
}
32+
}
33+
},
34+
"dataset_categories": {
35+
"title": "dataset_categories",
36+
"type": "array",
37+
"description": "Dataset categories describe and provide more information about the dataset which can be used to classify, group, sort and filter datasets.",
38+
"items": {
39+
"required": ["category_value", "category_name"],
40+
"additionalProperties": false,
41+
"properties": {
42+
"category_value": {
43+
"type": "string",
44+
"title": "category_value",
45+
"description": "An explanation about the purpose of this instance.",
46+
"examples": ["Homo sapiens"]
47+
},
48+
"category_name": {
49+
"type": "string",
50+
"title": "category_name",
51+
"description": "An explanation about the purpose of this instance.",
52+
"enum": [
53+
"species",
54+
"molecule",
55+
"tag",
56+
"tags",
57+
"priority",
58+
"file_type",
59+
"status",
60+
"scope"
61+
]
62+
}
63+
}
64+
}
65+
}
66+
}
67+
},
68+
"extension_schema": {
69+
"title": "extension_schema",
70+
"type": "string",
71+
"format": "uri",
72+
"description": "The schema applied to the extension object",
73+
"examples": [
74+
"http://www.w3id.org/biocompute/extension_domain/example.json"
75+
]
76+
}
77+
}
78+
}

config/schemas/fhir_extension.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://w3id.org/biocompute/extension_domain/1.1.0/fhir/fhir_extension.json",
4+
"title": "fhir_extension",
5+
"type": "object",
6+
"description": "The external references extension to FHIR resource",
7+
"required": ["fhir_extension", "extension_schema"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"extension_schema": {
11+
"title": "extension_schema",
12+
"type": "string",
13+
"format": "uri",
14+
"description": "The schema applied to the extension object",
15+
"examples": [
16+
"http://www.w3id.org/biocompute/extension_domain/example.json"
17+
]
18+
},
19+
"fhir_extension": {
20+
"title": "",
21+
"type": "array",
22+
"decription": "",
23+
"items": {
24+
"required": ["fhir_endpoint", "fhir_version", "fhir_resources"],
25+
"properties": {
26+
"fhir_endpoint": {
27+
"type": "string",
28+
"description": "Base URI of FHIR server where the resources are stored",
29+
"examples": ["http://fhirtest.uhn.ca/baseDstu3"],
30+
"format": "uri"
31+
},
32+
"fhir_version": {
33+
"type": "string",
34+
"description": "FHIR version of the server endpoint"
35+
},
36+
"fhir_resources": {
37+
"type": "array",
38+
"items": {
39+
"type": "object",
40+
"required": ["fhir_resource", "fhir_id"],
41+
"properties": {
42+
"fhir_resource": {
43+
"type": "string",
44+
"description": "Type of FHIR resource used"
45+
},
46+
"fhir_id": {
47+
"type": "string",
48+
"description": "Server-specific identifier string"
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "http://www.w3id.org/biocompute/extension_domain/1.1.0/galaxy/galaxy_extension.json",
4+
"title": "galaxy_extension",
5+
"type": "object",
6+
"description": "The external references **example** extension for a Galaxy BCO.",
7+
"required": ["galaxy_extension", "extension_schema"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"extension_schema": {
11+
"type": "string",
12+
"format": "uri",
13+
"description": "The schema applied to the extension object",
14+
"examples": [
15+
"http://www.w3id.org/biocompute/extension_domain/example.json"
16+
]
17+
},
18+
"galaxy_extension": {
19+
"type": "object",
20+
"required": ["galaxy_url", "galaxy_version"],
21+
"properties": {
22+
"galaxy_url": {
23+
"type": "string",
24+
"description": "The base url for the galaxy instance used to create the BioCompute Object.",
25+
"examples": ["https://galaxy.aws.biochemistry.gwu.edu/"],
26+
"format": "uri"
27+
},
28+
"galaxy_version": {
29+
"type": "string",
30+
"description": "The specific version of the Galaxy software used to generate the BioCompute Object.",
31+
"examples": ["20.01"]
32+
}
33+
}
34+
}
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "http://www.w3id.org/biocompute/extension_domain/1.1.0/license/license_extension.json",
4+
"type": "object",
5+
"description": "The extension to add additional licenses.",
6+
"required": ["licence_extension", "extension_schema"],
7+
"additionalProperties": false,
8+
"properties": {
9+
"extension_schema": {
10+
"title": "extension_schema",
11+
"type": "string",
12+
"format": "uri",
13+
"description": "The schema applied to the extension object",
14+
"examples": [
15+
"http://www.w3id.org/biocompute/extension_domain/example.json"
16+
]
17+
},
18+
"licence_extension": {
19+
"required": ["data_license", "scripts_license"],
20+
"properties": {
21+
"data_license": {
22+
"type": "string",
23+
"examples": ["https://github.com/example/repo1"],
24+
"format": "uri"
25+
},
26+
"scripts_license": {
27+
"type": "string",
28+
"examples": ["https://github.com/example/repo1"],
29+
"format": "uri"
30+
}
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)