Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 18, 2019
1 parent 3800c8e commit 30521dc
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/update_metadata.py
Original file line number Diff line number Diff line change
@@ -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)
54 changes: 54 additions & 0 deletions examples/update_metadata.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 30521dc

Please sign in to comment.