-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fix(dashboard-export): Fixes datasetId is not replaced with datasetUuid in Dashboard export in 4.1.x #30425
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #30425 +/- ##
===========================================
+ Coverage 60.48% 83.92% +23.43%
===========================================
Files 1931 533 -1398
Lines 76236 38546 -37690
Branches 8568 0 -8568
===========================================
- Hits 46114 32348 -13766
+ Misses 28017 6198 -21819
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Could you write a unit test that would fail before and succeed after? That will help review the logic by stating the assumptions in a unit test. |
Happy to do so. Since I have no clue of the testing approach of Superset, could you help me find the correct spot to test? Would the correct file be:
or rather an integration test (since this also concerns code that also exports other resources:
|
After some more searching, the example data used in the tests comes from here: Searching for So, I would need to write code to create a dashboard with native filters from scratch? Or would there be a simpler way to write such test? I would need some guidance. |
@fmannhardt I created a PR to the covid vaccine example dashboard. I'm guessing you can probably add a test here: https://github.com/apache/superset/blob/master/tests/integration_tests/dashboards/commands_tests.py#L67 or update one of the tests to make sure when exporting native filter meta data is there. |
Hey @fmannhardt, Thanks for working on this fix! 🙏 Looking at the code changes, I noticed you have re-introduced that code block to If we need them in both places, should we consider to move this logic to a helper/etc method to make it DRYer? |
@Vitor-Avila I think it is required in both places to also invoke the export of the related datasets via
It seems to me that a completely different approach to separate the export to YAML/JSON and walking the dependency graph of the to be exported dashboard would be better. Maybe, first collecting all the dependencies and then going through the list of dependencies and exporting them. However, that would exceed the capacity that I have for contributing right now (and I am also not aware of any design decision that led to the current approach). I will try to add the test in the next few days. |
@fmannhardt @Vitor-Avila as this would be a regression for 4.1, let's I'd advise that we just add the tests and then if we need to refactor, refactor in a separate pr. |
It seems that I also need to write a fixture for the COVID dashboard, right? Bare with me, still exploring the setup of Superset testing and locally many other tests fail probably due to missing dependencies. I will try to look at this tomorrow. |
@fmannhardt thanks for working on this super critical regression. I will be reviewing this today and do my best to help unblock you. |
Note: this is a fix for a regression that was introduced by #26765 |
@fmannhardt you are correct - if there isn't a fixture that creates this dashboard + related assets, then you will need to add one. Let me know if you need help with this. |
Happy to help and thanks for the work on Superset. I may have time to look at this tomorrow (UTC+1). So, the existing fixtures hard code the dashboard and do not load from the examples? Just so I understand how to write it. It would be a copy of In case, it is easy for you to add the fixture I am also happy to update the test I wrote to work against it. |
@fmannhardt let me take a look how it's been implemented (my memory is rusty on these particular fixtures).. |
@fmannhardt I took a quick look at that particular fixture, and it seems to be mostly reusing existing logic. However, the data seems to be randomly generated for some reason. I'm not sure why, but maybe it's to avoid unnecessary web traffic. Please keep an open mind while working on the fixture, and if you feel some aspect could be improved compared to the World Bank fixture, then please by all means feel free to implement accordingly. I'm in UTC-0700, so I can help/review tomorrow morning my time if needed, likely after you've had a chance to take a stab at it first. |
@villebro I took another look but this would take me much more time to understand. I don't even need to data for the test. Only the have the COVID dashboard and its dataset loaded and available to be queries by UUID |
@fmannhardt I totally understand. Feel free to disable the added test - I'll open a PR that adds the necessary fixtures and re-enables the test. |
Test is disabled and current master branch is merged. |
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.
LGTM, leaving open for another day so others can chime in. Note: I'll finalize the tests this week.
@@ -190,6 +201,5 @@ def _export( | |||
if dataset_id is not None: | |||
dataset = DatasetDAO.find_by_id(dataset_id) | |||
if dataset: | |||
target["datasetUuid"] = str(dataset.uuid) |
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.
At the risk of introducing yet more regressions, I feel it would be cleaner to do the following:
if export_related:
for target in native_filter...
The point being, no sense in iterating over all datasets, if export_related
is False
, as we're not doing anything else here (look at how charts are exported above).
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.
Done. Since this is now only to invoke the dataset export, it is fine to have the condition before iterating.
/testenv up |
@sadpandajoe Ephemeral environment spinning up at http://35.167.172.107:8080. Credentials are |
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.
Spun up an ephemeral and verified import/export of native filters are working so going to approve
I'm merging now, will follow up with those tests. |
Ephemeral environment shutdown and build artifacts deleted. |
…id in Dashboard export in 4.1.x (#30425)
SUMMARY
Fixes #30424 by duplicating the code that rewrites the
native_filter_configuration
to usedatasetUuid
instead ofdatasetId
into the_file_content
method ofExportDashboardsCommand
.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before the
targets
attribute ofnative_filter_configuration
items includesdatasetId
:After it just has
datasetUuid
:TESTING INSTRUCTIONS
(1) Create a dashboard with any chart
(2) Add a single value filter for any column
(3) Export the dashboard
(4) Verify that
datasetUuid
is used to refer to the dataset and notdatasetId
ADDITIONAL INFORMATION