Commit 2101e36f authored by Eric Duminil's avatar Eric Duminil
Browse files

formatting

parent 860d7e25
...@@ -37,13 +37,17 @@ def remove_random_id(text: str) -> str: ...@@ -37,13 +37,17 @@ def remove_random_id(text: str) -> str:
return re.sub(r"^(20\d{6}_\d{4}_)?[a-z0-9]{4}_", "", text) return re.sub(r"^(20\d{6}_\d{4}_)?[a-z0-9]{4}_", "", text)
def clean_old_workflows(folder: Path, pattern: str = "20*.flow", hours: int = 1) -> None: def clean_old_workflows(
folder: Path, pattern: str = "20*.flow", hours: int = 1
) -> None:
"""Remove timestamped workflow folders older than `hours` from `folder`. """Remove timestamped workflow folders older than `hours` from `folder`.
Only deletes paths whose names match the random_id timestamp pattern. Only deletes paths whose names match the random_id timestamp pattern.
""" """
# TODO: Should it be called before simulation too? # TODO: Should it be called before simulation too?
cutoff = (datetime.datetime.now() - datetime.timedelta(hours=hours)).strftime("%Y%m%d_%H%M_") cutoff = (datetime.datetime.now() - datetime.timedelta(hours=hours)).strftime(
"%Y%m%d_%H%M_"
)
for path in sorted(folder.glob(pattern)): for path in sorted(folder.glob(pattern)):
if m := WORKFLOW_FOLDER_PATTERN.match(path.name): if m := WORKFLOW_FOLDER_PATTERN.match(path.name):
if m.group(1) < cutoff: if m.group(1) < cutoff:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment