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

feat: import/export dashboards via cli #6061

Merged

Conversation

arpit-agarwal
Copy link
Contributor

@arpit-agarwal arpit-agarwal commented Oct 9, 2018

This PR will add back changes of #5991 that were reverted by #6035. This PR will close #5821

The travis configuration changes resolved the postgres test stuck issue

@graceguo-supercat We can attach details of travis change as well for future reference.

@kristw
Copy link
Contributor

kristw commented Oct 9, 2018

@arpit-agarwal Is this rebased on top of current master?

@arpit-agarwal
Copy link
Contributor Author

@kristw Yes

However I see it is behind by 1 commit now due to latest commit of @graceguo-supercat .

@arpit-agarwal
Copy link
Contributor Author

@graceguo-supercat / @kristw

I am not sure why this is failing for postgres when exactly same test works for other db.

I think it is best to mock the db operations in this test as this code is written on top of existing functionality that is well tested.

I am removing tests for now and will raise a new PR with only tests.

let me know what you guys think?

@codecov-io
Copy link

codecov-io commented Oct 9, 2018

Codecov Report

Merging #6061 into master will decrease coverage by 0.22%.
The diff coverage is 31.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6061      +/-   ##
==========================================
- Coverage   77.81%   77.59%   -0.23%     
==========================================
  Files          46       47       +1     
  Lines        9446     9496      +50     
==========================================
+ Hits         7350     7368      +18     
- Misses       2096     2128      +32
Impacted Files Coverage Δ
superset/views/core.py 74.19% <0%> (+0.36%) ⬆️
superset/cli.py 50% <23.33%> (-3.61%) ⬇️
superset/dashboard_import_export_util.py 40.74% <40.74%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 361f588...04f2dfe. Read the comment docs.

@graceguo-supercat
Copy link

graceguo-supercat commented Oct 9, 2018

here is failed build, just for reference in the future:
https://travis-ci.org/apache/incubator-superset/jobs/439235984

if you follow the stack trace, it goes from assert_dash_equals => compare slice one by one => viz_type not match. Before we compare slices one by one, we sort slice by name. But i hit into a few times that a slice doesn't have a name, so handle it as ''. Is it possible that you also hit into cases that multiple slices don't have name, and cause slice comparison failed?

I am ok to merge this PR. but when you add unit test in new PR, please pay attention to this scenario.

Copy link

@graceguo-supercat graceguo-supercat left a comment

Choose a reason for hiding this comment

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

LGTM

@graceguo-supercat graceguo-supercat merged commit ee472af into apache:master Oct 9, 2018
@arpit-agarwal
Copy link
Contributor Author

Thanks @graceguo-supercat .
I am doing comparisons by id to avoid the confliclt.
I am exporting the dashboards already present in db so they should ideally match.

I am not sure why they will differ unless some other parallel execution modif the slices transitively
I will investigate further and raise the PR.

betodealmeida pushed a commit to lyft/incubator-superset that referenced this pull request Oct 12, 2018
* feat: import/export dashboards via cli

* style: fixed lint error

* test: added test for import and export util

* test: removing import test as it is causing integrity issues

Import is a wrapper around exist functionality so we can go ahead without a test or mock the actual db operation using https://docs.python.org/3/library/unittest.mock.html

And validate the wrapper operations only.

* test: remove test data file

* test: removed usage of reserved keyword id

* Fix: remove test that is causing unintended impact
@HimanshuArora1234
Copy link

Hello Just wanted to know if this feature has already been released ? if so then in which version of superset ? Thanks a lot. Keep doing the great work :)

Cheers,
Himanshu

@arpit-agarwal
Copy link
Contributor Author

This is released in 0.28

bipinsoniguavus pushed a commit to ThalesGroup/incubator-superset that referenced this pull request Dec 26, 2018
* feat: import/export dashboards via cli

* style: fixed lint error

* test: added test for import and export util

* test: removing import test as it is causing integrity issues

Import is a wrapper around exist functionality so we can go ahead without a test or mock the actual db operation using https://docs.python.org/3/library/unittest.mock.html

And validate the wrapper operations only.

* test: remove test data file

* test: removed usage of reserved keyword id

* Fix: remove test that is causing unintended impact
@arslanselcuk
Copy link

Hi everyone ,

I need exported dashboards to be imported to another environment from command line to deploy dashboards on DTAP street.

Is it possible to see an implementation of this feature? Somehow I could not find it, or maybe I could not understand how to use it.
Regards.

@ITNoesis
Copy link

ITNoesis commented Jul 1, 2020

Hello All,
Can someone give me an example of how to export and import a dashboard via commandline?

@ITNoesis
Copy link

ITNoesis commented Jul 1, 2020

Hello All,
Can someone give me an example of how to export and import a dashboard via commandline?

Guess I am answering my own question:

Export dashboards from containerized install of SuperSet:

-- Login to docker container running superset app:
docker exec -it --user=username superset_app bash

-- Export dashboards:
$pwd
/app
$superset export_dashboards -f filename_and_path
--Example:
$superset export_dashboards -f /app/test_exportdashboards.json

-- Copy the dashboard to localhost
docker cp superset_app:/app/test_exportdashboards.json /devtools/superset/dashboards

This however, will download all the dashboards and I did not see an option to download a specific one.
The only available options are:

/app$ superset export-dashboards --help
Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
INFO:superset.utils.logging_configurator:logging was configured successfully
/usr/local/lib/python3.6/site-packages/flask_caching/init.py:189: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
"Flask-Caching: CACHE_TYPE is set to null, "
Usage: superset export-dashboards [OPTIONS]

Export dashboards to JSON

Options:
-f, --dashboard-file TEXT Specify the the file to export to
-p, --print_stdout Print JSON to stdout
--help Show this message and exit.

Regards,
Arun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow import and export dashboards and charts by CLI
8 participants