Skip to content

Commit ffeece0

Browse files
committed
debugged singularity tests
1 parent 4080298 commit ffeece0

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

pydra/engine/environments.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def get_bindings(
147147
if isinstance(fileset, os.PathLike)
148148
else tuple(env_path / rel for rel in fileset.relative_fspaths)
149149
)
150+
151+
# Add the cache directory to the list of mounts
152+
bindings[task.cache_dir] = (f"{self.root}/{task.cache_dir}", "rw")
153+
150154
return bindings, input_updates
151155

152156

@@ -158,9 +162,6 @@ def execute(self, task: "Task[ShellDef]") -> dict[str, ty.Any]:
158162
# mounting all input locations
159163
mounts, input_updates = self.get_bindings(task=task, root=self.root)
160164

161-
# add the cache directory to the list of mounts
162-
mounts[task.cache_dir] = (f"{self.root}{task.cache_dir}", "rw")
163-
164165
docker_args = [
165166
"docker",
166167
"run",
@@ -202,8 +203,6 @@ def execute(self, task: "Task[ShellDef]") -> dict[str, ty.Any]:
202203
singularity_args = [
203204
"singularity",
204205
"exec",
205-
"-B",
206-
self.bind(task.cache_dir, "rw"),
207206
*self.xargs,
208207
]
209208
singularity_args.extend(

pydra/engine/helpers_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _single_template_formatting(
269269
# inp_fields = set(re.findall(r"{(\w+)(?:\.\w+)?(?::[0-9.]+f)?}", template))
270270

271271
if len(inp_fields) == 0:
272-
return template
272+
return Path(template)
273273

274274
val_dict = {}
275275
file_template = None

pydra/engine/tests/test_environments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def newcache(x):
131131
makedir(tmp_path, x)
132132

133133
cmd = "whoami"
134-
sing = Singularity(image="docker://alpine")
134+
sing = Singularity(image="docker://alpine", xargs=["--fakeroot"])
135135
Shelly = shell.define(cmd)
136136
shelly = Shelly()
137137
shelly_job = Task(
@@ -159,7 +159,7 @@ def newcache(x):
159159
makedir(tmp_path, x)
160160

161161
cmd = "whoami"
162-
sing = Singularity(image="docker://alpine")
162+
sing = Singularity(image="docker://alpine", xargs=["--fakeroot"])
163163
Shelly = shell.define(cmd)
164164
shelly = Shelly()
165165
shelly_job = Task(

pydra/engine/tests/test_singularity.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_singularity_2(plugin, tmp_path):
7070
worker=plugin, environment=Singularity(image=image), cache_dir=tmp_path
7171
) as sub:
7272
res = sub(singu)
73+
assert not res.errored, "\n".join(res.errors["error message"])
7374
assert res.outputs.stdout.strip() == " ".join(cmd[1:])
7475
assert res.outputs.return_code == 0
7576

@@ -110,11 +111,13 @@ def test_singularity_st_1(plugin, tmp_path):
110111
singu = Singu().split("executable", executable=cmd)
111112

112113
outputs = singu(
113-
plugin=plugin, environment=Singularity(image=image), cache_dir=tmp_path
114+
plugin=plugin,
115+
environment=Singularity(image=image, xargs=["--fakeroot"]),
116+
cache_dir=tmp_path,
114117
)
115-
assert outputs.stdout[0] == "root"
116-
assert outputs.stdout[1] == "/mnt/pydra"
117-
assert outputs.stdout[2] == ""
118+
assert outputs.stdout[0].strip() == "root"
119+
assert "/mnt/pydra" in outputs.stdout[1]
120+
assert outputs.stdout[2].strip() == "_task.pklz"
118121
assert outputs.return_code == [0, 0, 0]
119122

120123

@@ -161,11 +164,10 @@ def test_singularity_outputspec_1(plugin, tmp_path):
161164
)
162165
singu = Singu()
163166

164-
with Submitter(
165-
worker=plugin, environment=Singularity(image=image), cache_dir=tmp_path
166-
) as sub:
167+
with Submitter(environment=Singularity(image=image), cache_dir=tmp_path) as sub:
167168
res = sub(singu)
168169

170+
assert not res.errored, "\n".join(res.errors["error message"])
169171
assert res.outputs.stdout == ""
170172
assert res.outputs.newfile.fspath.exists()
171173

@@ -386,7 +388,7 @@ class Singu(ShellDef["Singu.Outputs"]):
386388

387389
class Outputs(ShellOutputs):
388390
out_file: File = shell.outarg(
389-
path_template="{orig_file}",
391+
path_template="{orig_file}.txt", # FIXME: Shouldn't have to specify the extension
390392
help="output file",
391393
)
392394

@@ -396,7 +398,7 @@ class Outputs(ShellOutputs):
396398
assert outputs.stdout == ""
397399
assert outputs.out_file.fspath.exists()
398400
# the file is copied, and than it is changed in place
399-
assert outputs.out_file.fspath.parent == singu.output_dir
401+
assert outputs.out_file.fspath.parent.parent == tmp_path
400402
with open(outputs.out_file) as f:
401403
assert "hi from pydra\n" == f.read()
402404
# the original file is unchanged

0 commit comments

Comments
 (0)