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

Importing assets not working properly #286

Closed
Mast3rSensei opened this issue Apr 19, 2024 · 4 comments
Closed

Importing assets not working properly #286

Mast3rSensei opened this issue Apr 19, 2024 · 4 comments

Comments

@Mast3rSensei
Copy link

Mast3rSensei commented Apr 19, 2024

I'm having problems when trying to import all my assets from an assets/ folder to a Superset app. The error is kinda weird: while importing a given slice, I get a KeyError because the dataset_uuid does not result to be present among the configs. However, if I try to manually change the dataset_uuid to the one the error points to be missing, I get the same KeyError, for the same slice, telling me that now is missing from configs the dataset_uuid that was previously set before I manually changed it.

2024-04-19 09:30:59,735:INFO:superset.models.helpers:Importing new slices Owner Revenue over time CommandException Traceback (most recent call last): File "/app/superset/commands/importers/v1/assets.py", line 154, in run self._import(db.session, self._configs) File "/app/superset/commands/importers/v1/assets.py", line 127, in _import config = update_id_refs(config, chart_ids, dataset_info) File "/app/superset/dashboards/commands/importers/v1/utils.py", line 137, in update_id_refs target["datasetId"] = dataset_info[dataset_uuid]["datasource_id"] KeyError: '87c25681-59f7-4882-a4fa-2aa36561523b'

Now, I might be wrong but I noticed something in the import_resources_individually() function of the .../preset_cli/cli/superset/sync/native/command.py module.

Screenshot 2024-04-19 at 10 58 41

It seems to me that the function is only extracting the dataset_uuid attribute from the dashboard yaml files, but it's completely disregarding the ['metadata']['native_filter_configuration']['id']['targets']['datasetUuid'] attribute from the filter info of the dashboard. This attribute is well known on Superset, which uses also a function called find_native_filter_datasets() to extract those from the assets when importing data.

I think the fact that superset-cli ignores that attribute creates problems, because I don't think it's a coincidence that this error is happening with a dataset that has no chart associated, but it's still used as a filter in a dashboard. It looks like the dataset is completely ignored or missing from the configs dict exactly because of this reason.

@Mast3rSensei
Copy link
Author

Soooo I actually fixed this directly on code. Not the most elegant solution but it proved that the import_resources_individually() function was missing the step of including also filters' datasetUuid in the assets configs.

I simply created a function that does that:
Screenshot 2024-04-19 at 16 42 06

And then I added the function in the import dict to be run along with get_charts_uuids when the asset is "dashboards", plus I added some more conditional logic:
Screenshot 2024-04-19 at 16 41 55

@Vitor-Avila
Copy link
Contributor

Hi @Mast3rSensei,

Thanks for reporting this issue and for the additional investigation. A potential fix is being discussed on this PR #269

Thank you!

@Mast3rSensei
Copy link
Author

Thank you @Vitor-Avila,

any news about that? It's some time now the PR has been opened and the author disappeared.

@Vitor-Avila
Copy link
Contributor

Addressed the issue here #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants