Skip to content

Commit

Permalink
cleanup_unused: allow dryrun (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
vieting authored Aug 1, 2023
1 parent 50f1924 commit 5525542
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sisyphus/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def remove_directories(dirs, message, move_postfix='.cleanup', mode='remove', fo
p.close()

input_var = 'UNSET'
if force:
if mode == 'dryrun':
input_var = 'n'
elif force:
input_var = 'y'

while input_var.lower() not in ('n', 'y'):
Expand Down Expand Up @@ -295,12 +297,13 @@ def cleanup_keep_value(min_keep_value, load_from: str = '', mode: str = 'remove'
force=False)


def cleanup_unused(load_from: str = '', job_dirs=None):
def cleanup_unused(load_from: str = '', job_dirs=None, mode='remove'):
""" Check work directory and remove all subdirectories which do not belong to the given list of directories.
If no input is given it removes everything that is not in the current graph
:param load_from: File name to load list with used directories
:param job_dirs: Already loaded list of used directories
:param mode: Cleanup mode ('remove', 'move', or 'dryrun')
:return:
"""
if job_dirs:
Expand All @@ -310,4 +313,4 @@ def cleanup_unused(load_from: str = '', job_dirs=None):
else:
job_dirs = list_all_graph_directories()
to_remove = search_for_unused(job_dirs, verbose=True)
remove_directories(to_remove, 'Not used in graph', mode='remove', force=False)
remove_directories(to_remove, 'Not used in graph', mode=mode, force=False)

0 comments on commit 5525542

Please sign in to comment.