Skip to content

Commit 4af65c3

Browse files
lguerardclaude
andauthored
refactor(workflow): ♻️ guard the stage store with a touch() sentinel (#29)
Replace the prepare rule's directory(STAGE) output with a touch()ed STAGE_OK marker (sopa's sentinel discipline). Snakemake then tracks a tiny leaf file instead of a directory, so it no longer deletes/recreates (or "moves") the stage store on a re-run and is immune to directory-mtime quirks. segment depends on the sentinel; scripts open the store by path. With this + marker outputs + rerun-triggers: mtime, touching any script yields "Nothing to be done", and losing one tile re-runs only that tile and the merge — convert/prepare stay cached. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 32ae974 commit 4af65c3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

workflow/rules/common.smk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ IMAGE = f"{WORK}/image.zarr"
99
IMAGE_OK = f"{IMAGE}/zarr.json"
1010
TILES = f"{WORK}/tiles.json"
1111
STAGE = f"{WORK}/stage.zarr"
12+
# Completion sentinel for the stage store. Tracking a touch()ed marker instead
13+
# of directory(STAGE) keeps Snakemake from deleting/recreating the store on a
14+
# re-run and avoids directory-mtime quirks (same touch() discipline as sopa).
15+
STAGE_OK = f"{STAGE}.done"
1216

1317

1418
def occupied_done(wildcards):

workflow/rules/segment.smk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ checkpoint prepare:
55
IMAGE_OK,
66
output:
77
tiles=TILES,
8-
stage=directory(STAGE),
8+
stage=touch(STAGE_OK),
99
script:
1010
"../scripts/prepare_tiles.py"
1111

@@ -14,7 +14,7 @@ rule segment:
1414
"""Segment one tile on a GPU and write it into the stage store."""
1515
input:
1616
tiles=TILES,
17-
stage=STAGE,
17+
stage=STAGE_OK,
1818
image=IMAGE_OK,
1919
output:
2020
f"{WORK}/seg/{{index}}.done",

0 commit comments

Comments
 (0)