Skip to content

Commit e4644a5

Browse files
committed
removing temporary old env, some renaming
1 parent 25f14a2 commit e4644a5

File tree

4 files changed

+13
-41
lines changed

4 files changed

+13
-41
lines changed

pydra/engine/environments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def execute(self, task, root="/mnt/pydra"):
5555
# Skips over any inputs in task.cache_dir
5656
# Needs to include `out_file`s when not relative to working dir
5757
# Possibly a `TargetFile` type to distinguish between `File` and `str`?
58-
mounts = task.get_inputs_in_root(root=root)
58+
mounts = task.get_bindings(root=root)
5959

6060
# todo adding xargsy etc
6161
docker_args = ["docker", "run", "-v", self.bind(task.cache_dir, "rw")]

pydra/engine/task.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
<https://colab.research.google.com/drive/1RRV1gHbGJs49qQB1q1d5tQEycVRtuhw6>`__
3939
4040
"""
41+
from __future__ import annotations
42+
4143
import platform
4244
import re
4345
import attr
@@ -62,7 +64,6 @@
6264
)
6365
from .helpers import (
6466
ensure_list,
65-
execute,
6667
position_sort,
6768
argstr_formatting,
6869
output_from_inputfields,
@@ -354,7 +355,7 @@ def get_bindings(self, root: str | None = None) -> dict[str, tuple[str, str]]:
354355
if root is None:
355356
return {}
356357
else:
357-
self._check_inputs(root=root)
358+
self._prepare_bindings(root=root)
358359
return self.bindings
359360

360361
def command_args(self, root=None):
@@ -574,29 +575,7 @@ def cmdline(self):
574575
def _run_task(self, environment=None):
575576
if environment is None:
576577
environment = self.environment
577-
578-
if (
579-
environment == "old"
580-
): # TODO this is just temporarily for testing, remove this part
581-
if isinstance(self, ContainerTask):
582-
args = self.container_args + self.command_args()
583-
else:
584-
args = self.command_args()
585-
if args:
586-
# removing empty strings
587-
args = [str(el) for el in args if el not in ["", " "]]
588-
keys = ["return_code", "stdout", "stderr"]
589-
values = execute(args, strip=self.strip)
590-
self.output_ = dict(zip(keys, values))
591-
if self.output_["return_code"]:
592-
msg = f"Error running '{self.name}' task with {args}:"
593-
if self.output_["stderr"]:
594-
msg += "\n\nstderr:\n" + self.output_["stderr"]
595-
if self.output_["stdout"]:
596-
msg += "\n\nstdout:\n" + self.output_["stdout"]
597-
raise RuntimeError(msg)
598-
else:
599-
self.output_ = environment.execute(self)
578+
self.output_ = environment.execute(self)
600579

601580
def _prepare_bindings(self, root: str):
602581
"""Prepare input files to be passed to the task
@@ -721,7 +700,7 @@ def bind_paths(self):
721700
mount points: dict
722701
mapping from local path to tuple of container path + mode
723702
"""
724-
self._check_inputs()
703+
self._prepare_bindings()
725704
return {**self.bindings, **{self.output_dir: (self.output_cpath, "rw")}}
726705

727706
def binds(self, opt):
@@ -736,7 +715,7 @@ def binds(self, opt):
736715
bargs.extend([opt, f"{lpath}:{cpath}:{mode}"])
737716
return bargs
738717

739-
def _check_inputs(self):
718+
def _prepare_bindings(self):
740719
fields = attr_fields(self.inputs)
741720
for fld in fields:
742721
if TypeParser.contains_type(FileSet, fld.type):

pydra/engine/tests/test_dockertask.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ def test_docker_1_nosubm():
1717
no submitter
1818
"""
1919
cmd = "whoami"
20-
docky = DockerTask(name="docky", executable=cmd, image="busybox", environment="old")
21-
assert docky.inputs.image == "busybox"
22-
assert docky.inputs.container == "docker"
23-
assert (
24-
docky.cmdline
25-
== f"docker run --rm -v {docky.output_dir}:/output_pydra:rw -w /output_pydra {docky.inputs.image} {cmd}"
20+
docky = ShellCommandTask(
21+
name="docky", executable=cmd, environment=Docker(image="busybox")
2622
)
23+
assert docky.environment.image == "busybox"
24+
assert docky.environment.tag == "latest"
25+
assert isinstance(docky.environment, Docker)
26+
assert docky.cmdline == cmd
2727

2828
res = docky()
2929
assert res.output.stdout == "root\n"

pydra/engine/tests/test_environments.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ def test_native_1(tmp_path):
4646
shelly_subm(submitter=sub, environment=Native())
4747
assert env_res == shelly_subm.result().output.__dict__
4848

49-
# TODO: should be removed at the end
50-
shelly_old = ShellCommandTask(
51-
name="shelly_old", executable=cmd, cache_dir=tmp_path, environment="old"
52-
)
53-
shelly_old()
54-
assert env_res == shelly_old.result().output.__dict__
55-
5649

5750
@no_win
5851
@need_docker

0 commit comments

Comments
 (0)