-
Notifications
You must be signed in to change notification settings - Fork 16.5k
chore(dao): Condense delete/bulk-delete operations #24466
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
chore(dao): Condense delete/bulk-delete operations #24466
Conversation
superset/daos/annotation.py
Outdated
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.
Copypasta except the BaseDAO is defined as a classmethod as opposed to a staticmethod.
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.
These comments are very helpful while reviewing. Thank you.
superset/daos/annotation.py
Outdated
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.
Copypasta except the BaseDAO is defined as a classmethod as opposed to a staticmethod.
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.
Nice cleanup!
superset/daos/css.py
Outdated
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.
Copypasta except the BaseDAO is defined as a classmethod as opposed to a staticmethod.
Codecov Report
@@ Coverage Diff @@
## master #24466 +/- ##
===========================================
- Coverage 69.08% 58.33% -10.75%
===========================================
Files 1906 1906
Lines 74156 74107 -49
Branches 8161 8165 +4
===========================================
- Hits 51232 43234 -7998
- Misses 20805 28750 +7945
- Partials 2119 2123 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 267 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
2208e64 to
51dc939
Compare
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.
No need to return the object we're deleting.
5b99d4b to
8b63521
Compare
superset/dashboards/api.py
Outdated
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'm somewhat surprised that #24465 didn't pick this up.
02e8b79 to
cbb621d
Compare
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.
This logic is temporary. It should be cleaned up when we refactor the commands and enforce that validate doesn't augment any properties.
superset/daos/dataset.py
Outdated
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.
This is more accurate, i.e., the DatasetColumnDAO rather than the DatasetDAO should be deleting the column.
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.
DRY. The validate method already raises a DatasetMetricNotFoundError if the metric is not found.
superset/daos/base.py
Outdated
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.
items seems to be a more accurate/consistent than models, i.e., we're deleting database items/instances as opposed to models.
ee29647 to
3620631
Compare
superset/daos/dataset.py
Outdated
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.
The bulk_deletion logic differs from the delete logic in the sense that the former first deletes the relationships (which in actuality may not be explicitly required) before deleting the dataset, whereas the later only deletes the datasets (which in theory should delete all the records with an explicit relationship).
3620631 to
aa543ae
Compare
aa543ae to
14664d8
Compare
14664d8 to
6aaeed0
Compare
michael-s-molina
left a comment
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
superset/daos/annotation.py
Outdated
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.
These comments are very helpful while reviewing. Thank you.
superset/daos/annotation.py
Outdated
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.
Nice cleanup!
|
Thank you for the nice cleanup @john-bodley! |
Co-authored-by: Michael S. Molina <[email protected]>
Co-authored-by: Michael S. Molina <[email protected]> (cherry picked from commit 7409289)
Co-authored-by: Michael S. Molina <[email protected]>
SUMMARY
Per SIP-92 Proposal for restructuring the Python code base #24331 organized all the DAOs to be housed within a shared folder—the result of which highlighted numerous inconsistencies, repetition, and inefficiencies.
This PR (one of many smaller bitesized PRs) condenses the single (
delete) and bulk deletion (bulk_delete) logic into a single (delete) method which removes a bunch of copypasta and helps to standardize the code.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION