-
Notifications
You must be signed in to change notification settings - Fork 63
chore: Add cleanup step for old UDFs in anonymous dataset #2171
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
base: main
Are you sure you want to change the base?
Conversation
| def _cleanup_old_udfs(self): | ||
| """Clean up old UDFs in the anonymous dataset.""" | ||
| dataset = self._session._anon_dataset_manager.dataset | ||
| routines = list(self._session.bqclient.list_routines(dataset)) | ||
| cleanup_cutoff_time = datetime.datetime.now( | ||
| datetime.timezone.utc | ||
| ) - datetime.timedelta(days=_UDF_CLEANUP_THRESHOLD_DAYS) | ||
|
|
||
| for routine in routines: | ||
| if ( | ||
| routine.created < cleanup_cutoff_time | ||
| and routine._properties["routineType"] == "SCALAR_FUNCTION" | ||
| ): | ||
| try: | ||
| self._session.bqclient.delete_routine(routine.reference) | ||
| except Exception: | ||
| pass |
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.
Seems this code should just be in the AnonymousDatasetManager itself? Also, are we sure on the timing of when we want to trigger this?
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.
Also, maybe some tests to validate the behavior?
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes b/450913424 🦕