Skip to content

Commit c2dfa12

Browse files
committed
fix: only trigger script with CODE label
1 parent 26fcd38 commit c2dfa12

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/snakemake/dag.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,15 +1447,15 @@ async def updated_input():
14471447
# for determining any other changes than file modification dates, as it will
14481448
# change after evaluating the input function of the job in the second pass.
14491449

1450-
# The list comprehension is needed below in order to
1451-
# collect all the async generator items before
1452-
# applying any().
1453-
reason.code_changed = any(
1454-
[
1455-
f
1456-
async for f in job.outputs_older_than_script_or_notebook()
1457-
]
1458-
)
1450+
if RerunTrigger.CODE in self.workflow.rerun_triggers:
1451+
# job metadata can be missed, but the separate scripts don't.
1452+
# but it should not work if unwanted
1453+
reason.code_changed = any(
1454+
[
1455+
f
1456+
async for f in job.outputs_older_than_script_or_notebook()
1457+
]
1458+
)
14591459
if not self.workflow.persistence.has_metadata(job):
14601460
reason.no_metadata = True
14611461
elif self.workflow.persistence.has_outdated_metadata(job):

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from os.path import join
1414
import tempfile
1515
import hashlib
16-
import urllib
16+
import urllib.request
1717
import pytest
1818
import glob
1919
import subprocess

tests/tests.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,19 @@ def test_empty_include():
479479

480480

481481
def test_script_python():
482-
run(dpath("test_script_py"))
482+
tmpdir = run(dpath("test_script_py"), cleanup=False)
483+
outfile_path = os.path.join(tmpdir, "test.out")
484+
outfile_timestamp_orig = os.path.getmtime(outfile_path)
485+
# update timestamp but not contents of input file
486+
script_file = os.path.join(tmpdir, "scripts/test.py")
487+
os.utime(script_file)
488+
run(
489+
dpath("test_script_py"),
490+
rerun_triggers=frozenset([RerunTrigger.MTIME]),
491+
cleanup=False,
492+
)
493+
outfile_timestamp_new = os.path.getmtime(outfile_path)
494+
assert outfile_timestamp_orig == outfile_timestamp_new
483495

484496

485497
@skip_on_windows # Test relies on perl

0 commit comments

Comments
 (0)