From 30521dc7393b65ef51a5fd42b63b1dece46a2d5c Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Mon, 18 Nov 2019 17:53:50 +0100 Subject: [PATCH] Add examples --- examples/update_metadata.py | 27 ++++++++++++++++++ examples/update_metadata.yml | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 examples/update_metadata.py create mode 100644 examples/update_metadata.yml diff --git a/examples/update_metadata.py b/examples/update_metadata.py new file mode 100644 index 0000000..b8d878b --- /dev/null +++ b/examples/update_metadata.py @@ -0,0 +1,27 @@ +import yaml +from daiquiri_client import Client + +DAIQUIRI_URL = 'http://localhost:8000' +TOKEN = '' + +with open('update_metadata.yml') as f: + local_schemas = yaml.safe_load(f.read()) + +client = Client(DAIQUIRI_URL, TOKEN) + +for remote_schema in client.metadata.get_schemas(nested=True): + for local_schema in local_schemas: + if remote_schema['name'] == local_schema['name']: + client.metadata.update_schema(remote_schema['id'], local_schema) + + for remote_table in remote_schema['tables']: + for local_table in local_schema['tables']: + + if remote_table['name'] == local_table['name']: + client.metadata.update_table(remote_table['id'], local_table) + + for remote_column in remote_table['columns']: + for local_column in local_table['columns']: + + if remote_column['name'] == local_column['name']: + client.metadata.update_column(remote_column['id'], local_column) diff --git a/examples/update_metadata.yml b/examples/update_metadata.yml new file mode 100644 index 0000000..d9e061f --- /dev/null +++ b/examples/update_metadata.yml @@ -0,0 +1,54 @@ +- name: daiquiri_data_obs + title: Observational data + description: Some observational data + long_description: Some more information about the data. + attribution: Please cite the following paper ... + order: 1 + license: CC0 + doi: 10.1000/xyz123 + published: 2020-01-01 + updated: 2018-01-01 + access_level: PUBLIC + metadata_access_level: PUBLIC + creators: + - name: Anna Admin + first_name: Anna + last_name: Admin + orcid: https://orcid.org/0000-0001-2345-6789 + affiliations: "Institute of applied Administration\nInstitute of theoretical Managament" + - name: Manni Manager + orcid: https://orcid.org/0000-0001-2345-6790 + affiliations: Institute of theoretical Managament + contributors: + - name: Some computer guy + + tables: + - name: stars + title: Stars + description: Some stars data + order: 1 + license: CC0 + doi: 10.1000/xyz123/123 + published: 2020-01-01 + updated: 2018-01-01 + access_level: PUBLIC + metadata_access_level: PUBLIC + creators: + - name: Anna Admin + first_name: Anna + last_name: Admin + orcid: https://orcid.org/0000-0001-2345-6789 + affiliations: "Institute of applied Administration\nInstitute of theoretical Managament" + - name: Manni Manager + orcid: https://orcid.org/0000-0001-2345-6790 + affiliations: Institute of theoretical Managament + + columns: + - name: id + ucd: meta.id;meta.main + - name: ra + ucd: pos.eq.ra;meta.main + - name: dec + ucd: pos.eq.dec;meta.main + - name: parallax + ucd: pos.parallax