Remove empty experiment dirs#242
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the experiment directory management to prevent accidental overwrites and automatically clean up empty directories. The experiment_directory() function now returns a tuple (Path, bool) indicating both the directory path and whether it already exists. Schedulers gain the ability to prompt users for confirmation before overwriting existing experiments and automatically delete empty experiment directories when the GlobalSettings context exits.
- Modified
experiment_directory()to return whether the directory exists without creating it - Added user confirmation prompts to prevent accidental overwrites of existing experiments
- Implemented automatic cleanup of empty experiment directories via a scheduler registry
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/queens/utils/config_directories.py |
Changed experiment_directory() return type to tuple including existence flag |
src/queens/schedulers/_scheduler.py |
Added user confirmation prompt, cleanup registry, and local experiment directory management |
src/queens/schedulers/local.py |
Added overwrite_existing_experiment parameter and uses new experiment directory logic |
src/queens/schedulers/pool.py |
Added overwrite_existing_experiment parameter and uses new experiment directory logic |
src/queens/schedulers/cluster.py |
Added remote/local experiment directory methods and overwrite handling |
src/queens/schedulers/_dask.py |
Refactored to use cleanup registry instead of shutdown client list |
src/queens/global_settings.py |
Changed to call scheduler cleanup functions instead of client shutdown |
src/queens/drivers/jobscript.py |
Updated to use create_folder_if_not_existent() helper |
tests/unit_tests/tutorials/test_tutorials.py |
Mocks base_directory to prevent writing to user's home during tests |
tests/unit_tests/schedulers/test_experiment_dir.py |
New test file for experiment directory creation and overwrite behavior |
tests/unit_tests/drivers/test_jobscript.py |
Replaced local experiment_name fixture with shared test_name fixture |
tests/integration_tests/fourc/test_fourc_mc.py |
Updated to unpack tuple from experiment_directory() |
tests/integration_tests/fourc/test_fourc_mc_random_material_field.py |
Updated to unpack tuple from experiment_directory() |
tests/integration_tests/cluster/test_dask_cluster.py |
Updated mock and added comprehensive experiment directory tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
435dbda to
3b9671b
Compare
6170ece to
5f72d64
Compare
5f72d64 to
8fea8e7
Compare
|
Would it be possible to delay the creation of the experiment directory by removing |
You are right that we could delay the creation of the experiment directory until |
8fea8e7 to
622c4b8
Compare
Aren't the log files still written by the scheduler in this case? |
Only for the Cluster scheduler. If you use either the Local or the Pool scheduler, no log files or any other outputs are written to the experiment directory by the scheduler itself. |
maxdinkel
left a comment
There was a problem hiding this comment.
The changes look good to me. Thank you for your efforts :)
Description and Context:
What and Why?
This PR introduces the deletion of empty experiment directories when exiting the global settings context.
Related Issues and Pull Requests
Interested Parties
@sbrandstaeter