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: handle new export in CLI #11803

Merged
merged 7 commits into from
Dec 15, 2020
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Nov 24, 2020

SUMMARY

This PR adds the new export functionality to the superset CLI, when the VERSIONED_EXPORT feature flag is enabled.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

Tested with:

$ superset export-dashboards
$ superset export-datasources

Verified that files were correct.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@pull-request-size pull-request-size bot added size/M and removed size/L labels Nov 25, 2020
@betodealmeida betodealmeida marked this pull request as ready for review November 25, 2020 00:15
@betodealmeida betodealmeida requested review from hughhhh and removed request for john-bodley November 25, 2020 00:15
@codecov-io
Copy link

codecov-io commented Nov 25, 2020

Codecov Report

Merging #11803 (4911039) into master (14ea444) will decrease coverage by 13.10%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #11803       +/-   ##
===========================================
- Coverage   66.22%   53.11%   -13.11%     
===========================================
  Files         937      438      -499     
  Lines       45325    15714    -29611     
  Branches     4341     4060      -281     
===========================================
- Hits        30016     8347    -21669     
+ Misses      15177     7367     -7810     
+ Partials      132        0      -132     
Flag Coverage Δ
cypress 53.11% <ø> (+8.75%) ⬆️
javascript ?
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...uperset-frontend/src/dashboard/util/dnd-reorder.js 0.00% <0.00%> (-100.00%) ⬇️
...rset-frontend/src/dashboard/util/getEmptyLayout.js 0.00% <0.00%> (-100.00%) ⬇️
...dashboard/components/resizable/ResizableHandle.jsx 0.00% <0.00%> (-100.00%) ⬇️
.../src/dashboard/util/getFilterScopeFromNodesTree.js 0.00% <0.00%> (-93.48%) ⬇️
...src/dashboard/components/gridComponents/Header.jsx 10.52% <0.00%> (-86.85%) ⬇️
...rc/dashboard/components/gridComponents/Divider.jsx 13.33% <0.00%> (-86.67%) ⬇️
...ontend/src/dashboard/util/getDashboardFilterKey.ts 14.28% <0.00%> (-85.72%) ⬇️
...nd/src/views/CRUD/data/query/QueryPreviewModal.tsx 14.70% <0.00%> (-82.97%) ⬇️
...set-frontend/src/views/CRUD/welcome/EmptyState.tsx 5.71% <0.00%> (-82.10%) ⬇️
...et-frontend/src/SqlLab/components/TableElement.jsx 4.70% <0.00%> (-81.35%) ⬇️
... and 833 more

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 14ea444...4911039. Read the comment docs.


g.user = security_manager.find_user(username="admin")

dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
Copy link
Member

Choose a reason for hiding this comment

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

You can drop the () if you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think without the () it's easy to overlook what's happening:

dashboard_ids = [id_ for id_, in db.session.query(Dashboard.id).all()] 

Adding parentheses make the intent more clear, IMHO.

Copy link
Member

@dpgaspar dpgaspar Nov 27, 2020

Choose a reason for hiding this comment

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

[dashboard.id for dashboard in db.session.query(Dashboard.id).all()]

is clearer, but no strong opinions about it

Copy link
Member Author

Choose a reason for hiding this comment

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

@dpgaspar do you mean?

[dashboard.id for dashboard in db.session.query(Dashboard).all()]

That's a more expensive query (SELECT * FROM dbs instead of SELECT id FROM dbs), no?

Copy link
Member

Choose a reason for hiding this comment

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

yes, but no, I mean the way I wrote it that would generate a SELECT id from dbs but it's just a detail, if you feel more comfortable unpacking the tuples the way you wrote got ahead.

dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
root = f"dashboard_export_{timestamp}"
dashboard_file = dashboard_file or f"{root}.zip"
Copy link
Member

Choose a reason for hiding this comment

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

Should the default (fallback) be expressed as a click option?

Copy link
Member Author

Choose a reason for hiding this comment

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

I played with click trying to have options depend on the feature flag, but couldn't get it to work since it depends on the app context. Let me give it another try.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of non blocking comments

superset/cli.py Outdated Show resolved Hide resolved
superset/cli.py Outdated Show resolved Hide resolved
superset/cli.py Outdated Show resolved Hide resolved
@betodealmeida betodealmeida merged commit 862c251 into apache:master Dec 15, 2020
feature_flags_func = config.GET_FEATURE_FLAGS_FUNC
if feature_flags_func:
# pylint: disable=not-callable
feature_flags = feature_flags_func(feature_flags)
Copy link
Member

@ktmud ktmud Dec 16, 2020

Choose a reason for hiding this comment

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

This breaks the CLI when feature_flags_func uses g.user or any other app context based variables, which seems to be the original intention of GET_FEATURE_FLAGS_FUNC.

RuntimeError: Working outside of application context.

cc @betodealmeida @dpgaspar

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a quick workaround in #12088.

john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Dec 17, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 labels Mar 12, 2024
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 size/L 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants