Skip to content

Commit 9f2d59f

Browse files
committed
more debugging of singularity
1 parent 069e6f5 commit 9f2d59f

File tree

3 files changed

+48
-41
lines changed

3 files changed

+48
-41
lines changed

pydra/design/shell.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ def make(
345345
klass = None
346346
input_helps, output_helps = {}, {}
347347

348+
if isinstance(wrapped, list):
349+
wrapped = " ".join(wrapped)
350+
348351
executable, inferred_inputs, inferred_outputs = parse_command_line_template(
349352
wrapped,
350353
inputs=inputs,

pydra/engine/submitter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,20 @@ def Split(defn: TaskDef, output_types: dict):
211211

212212
task_def = Split(defn=task_def, output_types=output_types)
213213

214+
environment = None
214215
elif task_def._combiner:
215216
raise ValueError(
216217
f"Task {self} is marked for combining, but not splitting. "
217218
"Use the `split` method to split the task before combining."
218219
)
220+
else:
221+
environment = self.environment
222+
219223
task = Task(
220224
task_def,
221225
submitter=self,
222226
name="main",
223-
environment=self.environment,
227+
environment=environment,
224228
hooks=hooks,
225229
)
226230
try:

pydra/engine/tests/test_environments.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ def newcache(x):
3434

3535
shelly_job = Task(
3636
definition=shelly,
37-
submitter=Submitter(cache_dir=newcache("shelly-task")),
38-
name="shelly",
37+
submitter=Submitter(cache_dir=newcache("native-task")),
38+
name="native",
3939
)
4040
env_outputs = Native().execute(shelly_job)
4141

42-
outputs = shelly(cache_dir=newcache("shelly-exec"))
42+
outputs = shelly(cache_dir=newcache("native-exec"))
4343
assert drop_stderr(env_outputs) == drop_stderr(attrs_values(outputs))
4444

45-
outputs = shelly(environment=Native(), cache_dir=newcache("shelly-call"))
45+
outputs = shelly(environment=Native(), cache_dir=newcache("native-call"))
4646
assert env_outputs == attrs_values(outputs)
4747

48-
with Submitter(cache_dir=newcache("shelly-submitter"), environment=Native()) as sub:
48+
with Submitter(cache_dir=newcache("native-submitter"), environment=Native()) as sub:
4949
result = sub(shelly)
5050
assert drop_stderr(env_outputs) == drop_stderr(attrs_values(result.outputs))
5151

@@ -66,15 +66,15 @@ def newcache(x):
6666

6767
shelly_job = Task(
6868
definition=shelly,
69-
submitter=Submitter(cache_dir=newcache("shelly")),
70-
name="shelly",
69+
submitter=Submitter(cache_dir=newcache("docker")),
70+
name="docker",
7171
)
7272
outputs_dict = docker.execute(shelly_job)
7373

74-
with Submitter(cache_dir=newcache("shelly_sub"), environment=docker) as sub:
74+
with Submitter(cache_dir=newcache("docker_sub"), environment=docker) as sub:
7575
result = sub(shelly)
7676

77-
outputs = shelly(environment=docker, cache_dir=newcache("shelly_call"))
77+
outputs = shelly(environment=docker, cache_dir=newcache("docker_call"))
7878
# If busybox isn't found locally, then the stderr will have the download progress from
7979
# the Docker auto-pull in it
8080
for key in ["stdout", "return_code"]:
@@ -106,19 +106,19 @@ def newcache(x):
106106
shelly = shell.define(cmd)()
107107
shelly_job = Task(
108108
definition=shelly,
109-
submitter=Submitter(cache_dir=newcache("shelly")),
110-
name="shelly",
109+
submitter=Submitter(cache_dir=newcache("docker")),
110+
name="docker",
111111
)
112112
assert shelly.cmdline == cmd
113113
outputs_dict = docker.execute(shelly_job)
114114

115115
with Submitter(
116-
worker="cf", cache_dir=newcache("shelly_sub"), environment=docker
116+
worker="cf", cache_dir=newcache("docker_sub"), environment=docker
117117
) as sub:
118118
result = sub(shelly)
119119
assert outputs_dict == attrs_values(result.outputs)
120120

121-
outputs = shelly(cache_dir=newcache("shelly_call"), environment=docker)
121+
outputs = shelly(cache_dir=newcache("docker_call"), environment=docker)
122122
assert outputs_dict == attrs_values(outputs)
123123

124124

@@ -136,17 +136,17 @@ def newcache(x):
136136
shelly = Shelly()
137137
shelly_job = Task(
138138
definition=shelly,
139-
submitter=Submitter(cache_dir=newcache("shelly")),
140-
name="shelly",
139+
submitter=Submitter(cache_dir=newcache("singu")),
140+
name="singu",
141141
)
142142
assert shelly.cmdline == cmd
143143
outputs_dict = sing.execute(shelly_job)
144144

145-
with Submitter(cache_dir=newcache("shelly_sub"), environment=sing) as sub:
145+
with Submitter(cache_dir=newcache("singu_sub"), environment=sing) as sub:
146146
results = sub(shelly)
147147
assert drop_stderr(outputs_dict) == drop_stderr(attrs_values(results.outputs))
148148

149-
outputs = shelly(environment=sing, cache_dir=newcache("shelly_call"))
149+
outputs = shelly(environment=sing, cache_dir=newcache("singu_call"))
150150
assert drop_stderr(outputs_dict) == drop_stderr(attrs_values(outputs))
151151

152152

@@ -164,19 +164,19 @@ def newcache(x):
164164
shelly = Shelly()
165165
shelly_job = Task(
166166
definition=shelly,
167-
submitter=Submitter(cache_dir=newcache("shelly")),
168-
name="shelly",
167+
submitter=Submitter(cache_dir=newcache("singu")),
168+
name="singu",
169169
)
170170
assert shelly.cmdline == cmd
171171
outputs_dict = sing.execute(shelly_job)
172172

173173
with Submitter(
174-
worker=plugin, environment=sing, cache_dir=newcache("shelly_sub")
174+
worker=plugin, environment=sing, cache_dir=newcache("singu_sub")
175175
) as sub:
176176
results = sub(shelly)
177177
assert drop_stderr(outputs_dict) == drop_stderr(attrs_values(results.outputs))
178178

179-
outputs = shelly(environment=sing, cache_dir=newcache("shelly_call"))
179+
outputs = shelly(environment=sing, cache_dir=newcache("singu_call"))
180180
# singularity gives info about cashed image in stderr
181181
assert drop_stderr(outputs_dict) == drop_stderr(attrs_values(outputs))
182182

@@ -218,14 +218,14 @@ def newcache(x):
218218
f.write("hello ")
219219

220220
shelly = shelly_with_input_factory(filename=filename, executable="cat")
221-
shelly_job = make_job(shelly, tmp_path, "shelly")
221+
shelly_job = make_job(shelly, tmp_path, "native")
222222
outputs_dict = Native().execute(shelly_job)
223223

224-
with Submitter(environment=Native(), cache_dir=newcache("shelly_sub")) as sub:
224+
with Submitter(environment=Native(), cache_dir=newcache("native_sub")) as sub:
225225
results = sub(shelly)
226226
assert outputs_dict == attrs_values(results.outputs)
227227

228-
outputs = shelly(environment=Native(), cache_dir=newcache("shelly_call"))
228+
outputs = shelly(environment=Native(), cache_dir=newcache("native_call"))
229229
assert outputs_dict == attrs_values(outputs)
230230

231231

@@ -247,12 +247,12 @@ def newcache(x):
247247
filename = [filename_1, filename_2]
248248

249249
shelly = shelly_with_input_factory(filename=None, executable="cat")
250-
with Submitter(environment=Native(), cache_dir=newcache("shelly")) as sub:
250+
with Submitter(environment=Native(), cache_dir=newcache("native")) as sub:
251251
results = sub(shelly.split(file=filename))
252252
assert [s.strip() for s in results.outputs.stdout] == ["hello", "hi"]
253253

254254
outputs = shelly.split(file=filename)(
255-
environment=Native(), cache_dir=newcache("shelly_call")
255+
environment=Native(), cache_dir=newcache("native_call")
256256
)
257257
assert [s.strip() for s in outputs.stdout] == ["hello", "hi"]
258258

@@ -273,14 +273,14 @@ def newcache(x):
273273
f.write("hello ")
274274

275275
shelly = shelly_with_input_factory(filename=filename, executable="cat")
276-
outputs_dict = docker.execute(make_job(shelly, tmp_path, "shelly"))
276+
outputs_dict = docker.execute(make_job(shelly, tmp_path, "docker"))
277277

278278
with Submitter(environment=docker, cache_dir=newcache("shell_sub")) as sub:
279279
results = sub(shelly)
280280

281281
assert outputs_dict == attrs_values(results.outputs)
282282

283-
outputs = shelly(environment=docker, cache_dir=newcache("shelly_call"))
283+
outputs = shelly(environment=docker, cache_dir=newcache("docker_call"))
284284
assert outputs_dict == attrs_values(outputs)
285285

286286

@@ -300,18 +300,18 @@ def newcache(x):
300300
f.write("hello ")
301301

302302
shelly = shelly_with_input_factory(filename=filename, executable="cat")
303-
shelly_job = make_job(shelly, tmp_path, "shelly_job")
303+
shelly_job = make_job(shelly, tmp_path, "docker_job")
304304
outputs_dict = docker.execute(shelly_job)
305305

306306
with Submitter(
307-
environment=docker, cache_dir=newcache("shelly_sub"), worker=plugin
307+
environment=docker, cache_dir=newcache("docker_sub"), worker=plugin
308308
) as sub:
309309
results = sub(shelly)
310310
with Submitter(worker=plugin) as sub:
311311
results = sub(shelly)
312312
assert outputs_dict == attrs_values(results.outputs)
313313

314-
outputs = shelly(environment=docker, cache_dir=newcache("shelly_call"))
314+
outputs = shelly(environment=docker, cache_dir=newcache("docker_call"))
315315
assert outputs_dict == attrs_values(outputs)
316316

317317

@@ -338,13 +338,13 @@ def newcache(x):
338338

339339
shelly = shelly_with_input_factory(filename=None, executable="cat")
340340

341-
with Submitter(environment=docker, cache_dir=newcache("shelly_sub")) as sub:
341+
with Submitter(environment=docker, cache_dir=newcache("docker_sub")) as sub:
342342
results = sub(shelly.split(file=filename))
343343

344344
assert [s.strip() for s in results.outputs.stdout] == ["hello", "hi"]
345345

346346
outputs = shelly.split(file=filename)(
347-
environment=docker, cache_dir=newcache("shelly_call")
347+
environment=docker, cache_dir=newcache("docker_call")
348348
)
349349
assert [s.strip() for s in outputs.stdout] == ["hello", "hi"]
350350

@@ -391,16 +391,16 @@ def newcache(x):
391391

392392
# execute does not create the cashedir, so this part will fail,
393393
# but I guess we don't want to use it this way anyway
394-
# shelly = create_shelly_outputfile(tempdir=tmp_path, filename=filename, name="shelly")
394+
# shelly = create_shelly_outputfile(tempdir=tmp_path, filename=filename, name="native")
395395
# outputs_dict = Native().execute(shelly)
396396

397397
shelly = shelly_outputfile_factory(filename=filename)
398398

399-
with Submitter(environment=Native(), cache_dir=newcache("shelly_sub")) as sub:
399+
with Submitter(environment=Native(), cache_dir=newcache("native_sub")) as sub:
400400
result = sub(shelly)
401401
assert Path(result.outputs.file_copy) == result.output_dir / "file_copy.txt"
402402

403-
call_cache = newcache("shelly_call")
403+
call_cache = newcache("native_call")
404404

405405
outputs = shelly(environment=Native(), cache_dir=call_cache)
406406
assert Path(outputs.file_copy) == call_cache / shelly._checksum / "file_copy.txt"
@@ -424,15 +424,15 @@ def newcache(x):
424424
filename = [filename_1, filename_2]
425425

426426
shelly = shelly_outputfile_factory(filename=None)
427-
with Submitter(environment=Native(), cache_dir=newcache("shelly")) as sub:
427+
with Submitter(environment=Native(), cache_dir=newcache("native")) as sub:
428428
results = sub(shelly.split(file_orig=filename))
429429

430430
assert [f.name for f in results.outputs.file_copy] == [
431431
"file_1_copy.txt",
432432
"file_2_copy.txt",
433433
]
434434

435-
call_cache = newcache("shelly_call")
435+
call_cache = newcache("native_call")
436436

437437
outputs = shelly.split(file_orig=filename)(
438438
environment=Native(), cache_dir=call_cache
@@ -457,7 +457,7 @@ def newcache(x):
457457

458458
shelly = shelly_outputfile_factory(filename=filename)
459459

460-
with Submitter(environment=docker_env, cache_dir=newcache("shelly")) as sub:
460+
with Submitter(environment=docker_env, cache_dir=newcache("docker")) as sub:
461461
results = sub(shelly)
462462
assert results.outputs.file_copy == File(results.output_dir / "file_copy.txt")
463463

@@ -485,7 +485,7 @@ def newcache(x):
485485

486486
shelly = shelly_outputfile_factory(filename=None)
487487

488-
with Submitter(environment=docker_env, cache_dir=newcache("shelly_sub")) as sub:
488+
with Submitter(environment=docker_env, cache_dir=newcache("docker_sub")) as sub:
489489
results = sub(shelly.split(file_orig=filename))
490490
assert [f.name for f in results.outputs.file_copy] == [
491491
"file_1_copy.txt",

0 commit comments

Comments
 (0)