diff options
| author | Frederick Muriuki Muriithi | 2026-04-15 14:48:41 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-15 14:48:41 -0500 |
| commit | 5a8f1d5368e6a4119cd73955c0d0ede0f98cce42 (patch) | |
| tree | 4b4f4ac2c1513a917918881be2e81f54cce81ae5 /scripts | |
| parent | af62ff14574d708a138b011a7089e085c4ad183c (diff) | |
| download | gn-uploader-5a8f1d5368e6a4119cd73955c0d0ede0f98cce42.tar.gz | |
Pull helper function out of main().
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/load_phenotypes_to_db.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py index 9b70fed..fedb9f8 100644 --- a/scripts/load_phenotypes_to_db.py +++ b/scripts/load_phenotypes_to_db.py @@ -459,6 +459,24 @@ if __name__ == "__main__": logging.getLogger("uploader.phenotypes.models").setLevel(log_level) + def __parse_resource_details__(meta) -> dict: + """Parse out details regarding the wrapper resource from the metadata.""" + _key_mappings_ = { + # allow both 'data_*' and 'data*' for the metadata. + "data_description": "description", + "datadescription": "description" + } + return { + "resource_name": meta.get(# at least one of these MUST be set. + "dataname", + meta["data_name"]), + "resource_metadata": { + rkey: meta[mkey] + for mkey, rkey in _key_mappings_.items() if mkey in meta + } + } + + def main(): """Entry-point for this script.""" args = parse_args() @@ -515,19 +533,6 @@ if __name__ == "__main__": logger.info("Updating authorisation.") _job_metadata = job["metadata"] - def __parse_resource_details__(meta) -> dict: - _key_mappings_ = { - "data_description": "description", - } - return { - "resource_name": _job_metadata["dataname"], - "resource_metadata": { - rkey: meta[mkey] - for mkey, rkey in _key_mappings_.items() - if mkey in meta - } - } - return update_auth((_job_metadata["authserver"], _job_metadata["token"]), __parse_resource_details__(_job_metadata), |
