-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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 #5991
Merged
mistercrunch
merged 6 commits into
apache:master
from
ThalesGroup:feat/dashboard_import_export_cli
Oct 1, 2018
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c6fe2df
feat: import/export dashboards via cli
627fdda
style: fixed lint error
f5d47f2
test: added test for import and export util
a1914dd
test: removing import test as it is causing integrity issues
f5922f5
test: remove test data file
a6545cc
test: removed usage of reserved keyword id
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# pylint: disable=C,R,W | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import json | ||
import logging | ||
import time | ||
|
||
from superset import utils | ||
from superset.models.core import Dashboard | ||
|
||
|
||
def import_dashboards(session, data_stream, import_time=None): | ||
"""Imports dashboards from a stream to databases""" | ||
current_tt = int(time.time()) | ||
import_time = current_tt if import_time is None else import_time | ||
data = json.loads(data_stream.read(), object_hook=utils.decode_dashboards) | ||
# TODO: import DRUID datasources | ||
for table in data['datasources']: | ||
type(table).import_obj(table, import_time=import_time) | ||
session.commit() | ||
for dashboard in data['dashboards']: | ||
Dashboard.import_obj( | ||
dashboard, import_time=import_time) | ||
session.commit() | ||
|
||
|
||
def export_dashboards(session): | ||
"""Returns all dashboards metadata as a json dump""" | ||
logging.info('Starting export') | ||
dashboards = session.query(Dashboard) | ||
dashboard_ids = [] | ||
for dashboard in dashboards: | ||
dashboard_ids.append(dashboard.id) | ||
data = Dashboard.export_dashboards(dashboard_ids) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mistercrunch @arpit-agarwal I've noticed this test failing the py36-postgres tests when a pr has not made any changes to this code. For example https://travis-ci.org/apache/incubator-superset/jobs/436740957 Can you take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mistercrunch @arpit-agarwal this is blocking merging all PRs into master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mistercrunch @arpit-agarwal this flaky test is still failing most builds for
py36-postgres
therefore blocking merges. Can you either PTAL or we will revert this PR if it's not fixed by noon today PDT?cc @john-bodley @kristw @michellethomas @graceguo-supercat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i made a test branch which reverted this whole PR, and it passed all CI tests. So i created #6035 to revert this. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank guys.
@graceguo-supercat @williaster @mistercrunch
However I don't understand how this PR can halt postgres.
I had seen stalled postgres even before this PR was merged. Look this job for a instance that was commit before this PR merged.
I also see build not passing after reverting the PR. see
We may need to find the first stalled build to see the root cause. I am out in a
pycon India
i will grok the logs once backThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arpit-agarwal Thank you very much for investigation. After I reverted this PR, what we observed is, most PRs passed all CI tests, includes postgres one. But master branch still failed at postgres test. Right now i am totally confused what exactly happened :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested we can look at the content of PR #5693 to fund the route cause.
I do see some changes in test in that PR related to test.
Any recent configruration changes on tarvis or postgress version or lsome python lib?