krsnik93 opened a new issue #13914:
URL: https://github.com/apache/superset/issues/13914


   I am trying to develop a procedure for moving charts, dashboards and other 
resources from one instance to another.
   
   I started with the simplest attempt: export dashboards from one superset 
instance and import them back in.
   
   Running `superset export-dashboards` creates a file called 
`dashboard_export_YYYYMMDDTHHMMSS`. The file is a .zip archive, which is 
difficult to know because the extension is missing. The `YYYYMMDDTHHMMSS` part 
of it is redundant and should be dropped. Upon unzipping the file, the contents 
are directories `charts`, `dashboards`, `databases`, `datasets` and a file 
called `metadata.yaml`. So even though the command is called 
`export-dashboards`, it actually exports other resource types as well. Not sure 
it's needed, certainly is unclear.
   
   Importing back a dashboard with:
    `superset import-dashboards --path 
dashboard_export_20210401T140536/dashboards/USA_Births_Names.yaml`
   gives:
   ```
   File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/superset/cli.py", 
line 318, in import_dashboards
       ImportDashboardsCommand(contents).run()
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 69, in run
       raise exc
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 58, in run
       command.run()
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/superset/dashboards/commands/importers/v0.py",
 line 325, in run
       self.validate()
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/superset/dashboards/commands/importers/v0.py",
 line 335, in validate
       json.loads(content)
     File "/usr/lib64/python3.8/json/__init__.py", line 357, in loads
       return _default_decoder.decode(s)
     File "/usr/lib64/python3.8/json/decoder.py", line 337, in decode
       obj, end = self.raw_decode(s, idx=_w(s, 0).end())
     File "/usr/lib64/python3.8/json/decoder.py", line 355, in raw_decode
       raise JSONDecodeError("Expecting value", s, err.value) from None
   json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
   ```
   So it expects a .json but receives a .yaml as exported.
   
   Then I tried a similar approach with `export-datasources` and 
`import-datasources`. Exporting also creates a .zip archive with the extension 
missing. Unzipping gives a bunch of .yaml files. Importing back with:
   `superset import-datasources --path 
dataset_export_20210401T141602/datasets/examples/random_time_series.yaml`
   gives:
   ```
   Traceback (most recent call last):
     File "/home/fedora/superset/venv/bin/superset", line 11, in <module>
       load_entry_point('apache-superset==1.0.1', 'console_scripts', 
'superset')()
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
829, in __call__
       return self.main(*args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/flask/cli.py", line 
586, in main
       return super(FlaskGroup, self).main(*args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
782, in main
       rv = self.invoke(ctx)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
1259, in invoke
       return _process_result(sub_ctx.command.invoke(sub_ctx))
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
1066, in invoke
       return ctx.invoke(self.callback, **ctx.params)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/decorators.py", 
line 21, in new_func
       return f(get_current_context(), *args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/flask/cli.py", line 
426, in decorator
       return __ctx.invoke(f, *args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/decorators.py", 
line 21, in new_func
       return f(get_current_context(), *args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/flask/cli.py", line 
426, in decorator
       return __ctx.invoke(f, *args, **kwargs)
     File 
"/home/fedora/superset/venv/lib64/python3.8/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
   TypeError: import_datasources() got an unexpected keyword argument 'sync'
   ```
   
   ### Expected results
   
   Expected to be able to import/export unchanged files smoothly.
   
   ### Actual results
   
   I might be using it wrong, but there seem to be many problems with this. 
File naming etc. is minor but the elementary .yaml/.json mismatch is really 
weird.
   
   #### How to reproduce the bug
   
   Described above in great detail.
   
   ### Environment
   
   - superset version: 1.0.1
   - python version: 3.8.7
   
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   I have encountered a similar problem when using REST API  instead of the CLI 
commands:
   https://github.com/apache/superset/issues/13239


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to