Skip to content

Commit

Permalink
fix: Disable Persistence cache for snakemake jobs (#1159)
Browse files Browse the repository at this point in the history
* Implement test_github_issue1158

* Disable Persistence cache for snakemake jobs

* test_github_issue1158 mark xfail if no strace

* Add tests/test_github_issue1158/expected-results
  • Loading branch information
veprbl committed Sep 5, 2021
1 parent ac3274a commit 7110f9d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions snakemake/workflow.py
Expand Up @@ -730,6 +730,9 @@ def files(items):
or delete_temp_output,
)

if self.mode in [Mode.subprocess, Mode.cluster]:
self.persistence.deactivate_cache()

if cleanup_metadata:
for f in cleanup_metadata:
self.persistence.cleanup_metadata(f)
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Expand Up @@ -9,6 +9,7 @@

skip_on_windows = pytest.mark.skipif(ON_WINDOWS, reason="Unix stuff")
only_on_windows = pytest.mark.skipif(not ON_WINDOWS, reason="Windows stuff")
needs_strace = pytest.mark.xfail(os.system("strace -o /dev/null true") != 0, reason="Missing strace")


@pytest.fixture(autouse=True)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_github_issue1158/Snakefile
@@ -0,0 +1,3 @@
rule Test:
output: "output"
shell: "touch {output}"
Empty file.
20 changes: 20 additions & 0 deletions tests/test_github_issue1158/qsub.py
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
import sys
import os
import random
import re

jobscript = sys.argv[1]

os.system("strace -f -o trace {}".format(jobscript))

with open("trace", "r") as fp:
lines = fp.readlines()

regex = re.compile('.*openat\(.*.snakemake/incomplete".*')
matches = list(filter(lambda l: regex.match(l), lines))
if len(matches) > 0:
sys.stderr.write(repr(matches))
sys.exit(1)

print(random.randint(1, 100))
10 changes: 9 additions & 1 deletion tests/tests.py
Expand Up @@ -12,7 +12,7 @@
sys.path.insert(0, os.path.dirname(__file__))

from .common import *
from .conftest import skip_on_windows, only_on_windows, ON_WINDOWS
from .conftest import skip_on_windows, only_on_windows, ON_WINDOWS, needs_strace


def test_list_untracked():
Expand Down Expand Up @@ -1306,3 +1306,11 @@ def test_all_temp():

def test_strict_mode():
run(dpath("test_strict_mode"), shouldfail=True)


@needs_strace
def test_github_issue1158():
run(
dpath("test_github_issue1158"),
cluster="./qsub.py",
)

0 comments on commit 7110f9d

Please sign in to comment.