Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import: Options to set dataset metadata #139

Merged
merged 1 commit into from
Jun 28, 2020
Merged

Conversation

craigds
Copy link
Member

@craigds craigds commented Jun 26, 2020

Description

Adds a --table-info option which adds extra dataset metadata via a JSON object. Fixes #102

The JSON object is a bit smelly, but I tried hard to think of a better way and couldn't. Because the import command now imports multiple tables at once, we need a way to set title, description and xml metadata for multiple layers at once.

Some alternatives I tried:

  1. sno import SRC table1 --title=title2 table2 --title=title2

This would probably be the nicest approach in terms of having a flat schema to the command line arguments, though it's a little at odds with how these commands generally work I think.

I couldn't find any simple way to do this in click. It's possible we could abuse multi-command chaining to do it if we tried really hard, but it'd be a hack.

  1. sno import SRC dataset1 dataset2 --dataset1-title title1 --dataset2-title title2

This would work but it once again seems hard to do in click. We'd basically have to give up on the parser and accept everything and handle validation ourselves.

  1. this approach.
  --table-info JSON               Specifies overrides for imported tables, in
                                  a nested JSON object.  Each key is a dataset
                                  name, and each value is an object.  Valid
                                  overrides are 'title', 'description' and
                                  'xmlMetadata'. e.g.:  --table-
                                  info='{"land_parcels": {"title": "Land
                                  Parcels 1:50k"}' To import from a file,
                                  prefix with `@`, e.g. `--table-
                                  info=@filename.json`

Screen Shot 2020-06-26 at 4 38 58 PM

The JSON validates to a schema, so if you do something unexpected, you'll get a verbose but slightly helpful error message:
Screen Shot 2020-06-26 at 4 37 48 PM

Related links:

Checklist:

  • Have you reviewed your own change?
  • Have you included test(s)?
  • Have you updated the changelog?

Copy link
Member

@rcoup rcoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a pretty good approach at the moment, and we can revisit with/after Dataset2

sno/cli_util.py Outdated Show resolved Hide resolved
@craigds craigds merged commit 32815a9 into master Jun 28, 2020
@craigds craigds deleted the import-table-info branch June 28, 2020 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add alternative ways of importing title, description, XML metadata
3 participants