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: Remove unused aspects assets on import #950

Merged
merged 11 commits into from
Oct 4, 2024

Conversation

saraburns1
Copy link
Contributor

@saraburns1 saraburns1 commented Sep 25, 2024

Closes #370

  1. create_assets.py - run during init and import-assets
    write to yaml file every uuid and it's translated asset uuids

  2. delete_assets.py - called within create_assets
    for each uuid in aspects_asset_list 'unused' and their corresponding translated uuids, DELETE assets from superset db

  3. delete_aspects_unused_assets.py - run during 'import_superset_zip' and 'check_superset_assets'
    if chart/dataset is not used AND is in aspects_asset_list under 'unused', DELETE yaml file
    if chart/dataset is not used (ignoring any uuid listed under 'ignored' in aspects_asset_list.yaml) print warning about potential unused assets

  4. Remove duplicate name check - not needed anymore since we append uuid to filename

image
image
image

@saraburns1 saraburns1 marked this pull request as ready for review September 25, 2024 17:48
Copy link
Contributor

@bmtcril bmtcril left a comment

Choose a reason for hiding this comment

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

Code LGTM, can you update the PR description with exactly what the changes are and put something in the readme about the new command? I don't think the old commands are in there anywhere but can you spin through and make sure?

README.rst Outdated Show resolved Hide resolved
Comment on lines 60 to 62
for id in id_list:
tag_command = DeleteTaggedObjectCommand(OBJECT_TYPES[asset_type], id)
tag_command.run()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary as per Superset 4.0.2, and on Superset 4.1.0 this should happen automatically by the backend

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does happen automatically, but if there are multiple tag rows per object (which there are locally at least) then it fails. I created an issue in the superset repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI - this will be fixed in the 4.1 superset release so we need to keep this code in for now

README.rst Outdated Show resolved Hide resolved
@saraburns1 saraburns1 changed the title feat: Remove unused aspects assets on import WIP - feat: Remove unused aspects assets on import Oct 2, 2024
@saraburns1 saraburns1 changed the title WIP - feat: Remove unused aspects assets on import feat: Remove unused aspects assets on import Oct 2, 2024
Copy link
Contributor

@bmtcril bmtcril left a comment

Choose a reason for hiding this comment

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

Worked for me! Thanks for all the work on this!

@Ian2012 Ian2012 merged commit 79de281 into openedx:main Oct 4, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

Feat: Delete known-orphaned Superset assets
3 participants