Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
2101e36f
Commit
2101e36f
authored
Sep 20, 2026
by
Eric Duminil
Browse files
formatting
parent
860d7e25
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/simstadt/utils.py
View file @
2101e36f
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment