Adding YAML Import/Export for Datasources to CLI#2993
Conversation
96e46fd to
378673b
Compare
|
Hi, I have not been able to integrate this code into the latest superset, so I was wondering if this script (https://github.com/tc-dc/superset/blob/DatasourceUpload/upload_datasources.py) that was mentioned in the discussion thread is still available? (The link is not working anymore). |
|
I'll push an updated version of this branch soon (by end of this week), I'm currently enhancing it for our CI environment. I have quite a few of these branches out and its pretty painful to keep them up to date. |
378673b to
df186d5
Compare
|
I think the build didn't trigger (Travis downtime?), looks ready to merge otherwise. |
|
Hi, I pulled your commit and all seemed to work fine. In particular, exporting to a yaml file worked well. However, importing seems to have some problem $superset import_datasources blob usage: superset [-?] (where this error happens whether blob is an actual file or just something that does not exist). And of course running without the second argument does not work either: superset import_datasources I also tried with a pipe, same error (cat whatever.yaml | superset import_datasources) Thanks |
|
Try And look at the documentation in this PR. |
|
Got it; I had not realized that superset import_datasources --help provided all the necessary info. Thank you and sorry for the dumb question. |
6972a07 to
2597da0
Compare
2597da0 to
40d28bf
Compare
|
Opened a new PR for this so travis would pick it up |
Context: https://groups.google.com/forum/#!topic/airbnb_superset/GeWZs42_NyA
Summary
Adding YAML import and export for datasources, which includes (SqlAlchemy) Databases and Druid Clusters to the Superset CLI.
Description
I added the core of the Import/Export logic to the
ImportMixinmix-in class. It heavily relies on SqlAlchemy to determine the schema of the YAML and the relationship of objects. Specifically it uses unique constraints to identify and update existing elements. This required me to add unique constraints to existing tables, but I'm pretty confident that this should not cause major issues with existing installations since I added them in the "spirit" of the current design.In addition to the SqlAlchemy relationships the main object hierarchy needs to be defined by configuring the
export_parentandexport_childrenattributes appropriately (documented in code).The unit test covers only basic importing exporting (it was liftet from the existing pickle import/export) and should probably be extended to cover more edge cases.
You can export databases, druid clusters, tables, datasources from the UI:

Possible Future Projects/Improvements