diff options
author | Peter Amstutz | 2020-07-08 16:17:09 -0400 |
---|---|---|
committer | Peter Amstutz | 2020-07-08 16:18:51 -0400 |
commit | ae8991618927f81343038f235c3e3f76932f80ea (patch) | |
tree | 426ee0b65a84eeccf20ef07eb04879073ddee4e3 | |
parent | cd25f56f4d9aea1d30cc17ee923a6d8dd6c63e5a (diff) | |
download | bh20-seq-resource-ae8991618927f81343038f235c3e3f76932f80ea.tar.gz bh20-seq-resource-ae8991618927f81343038f235c3e3f76932f80ea.tar.lz bh20-seq-resource-ae8991618927f81343038f235c3e3f76932f80ea.zip |
Avoid redundant loading of schema
-rw-r--r-- | bh20sequploader/qc_metadata.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py index 3e1e471..0a0c780 100644 --- a/bh20sequploader/qc_metadata.py +++ b/bh20sequploader/qc_metadata.py @@ -8,15 +8,20 @@ import traceback from rdflib import Graph, Namespace from pyshex.evaluate import evaluate +metadata_schema = None def qc_metadata(metadatafile): + global metadata_schema log = logging.getLogger(__name__ ) - schema_resource = pkg_resources.resource_stream(__name__, "bh20seq-schema.yml") - cache = {"https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml": schema_resource.read().decode("utf-8")} - (document_loader, - avsc_names, - schema_metadata, - metaschema_loader) = schema_salad.schema.load_schema("https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml", cache=cache) + if metadata_schema is None: + schema_resource = pkg_resources.resource_stream(__name__, "bh20seq-schema.yml") + cache = {"https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml": schema_resource.read().decode("utf-8")} + metadata_schema = schema_salad.schema.load_schema("https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml", cache=cache) + + (document_loader, + avsc_names, + schema_metadata, + metaschema_loader) = metadata_schema shex = pkg_resources.resource_stream(__name__, "bh20seq-shex.rdf").read().decode("utf-8") |