Implement cleanup of run files upon model session and run deletion - #829
Open
Creylay wants to merge 1 commit into
Open
Implement cleanup of run files upon model session and run deletion#829Creylay wants to merge 1 commit into
Creylay wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
Run.run_pathon disk can be either a file (scikit-learn/torch models) or a directory (Hugging Face models). SinceRun.idgets reused by SQLite once rows are deleted, a stale artifact left behind by one run could collide with a new run that lands on the same id, crashing training withIsADirectoryError/PermissionError. This same file-vs-directory assumption also brokeDELETE /run/{id}: deleting a run whoserun_pathwas a directory always failed with a 500, since it usedos.remove(files only) instead of a helper that handles both. Also fixes a related cleanup gap where deleting a model session never removed its runs' files from disk, letting stale artifacts orphan in the first place.Type of Change
Check all that apply like this [x]:
Changes (by file)
DashAI/back/job/model_job.py: clear any pre-existing file/directory atrun_pathbefore saving a trained model (root-cause fix).DashAI/back/api/api_v1/endpoints/runs.py:delete_runnow usesremove_p, so runs whoserun_pathis a directory (Hugging Face models) can actuallybe deleted.DashAI/back/api/api_v1/endpoints/model_sessions.py:delete_model_sessionnow cleans up therun_path/plot files of cascaded runs on disk instead of leaving them orphaned.DashAI/back/api/utils.py: relocated the sharedremove_pathhelper here el_job.py` can use it.tests/back/api/test_jobs.py,tests/back/api/test_runs_api.py: added regression tests for the three scenarios above.Testing
run_pathwas a directory (Hugging Face model). Deletion now succeeds instead of returning a 500.