diff --git a/pydra/environments/docker.py b/pydra/environments/docker.py index 03179f0da..3c6da919a 100644 --- a/pydra/environments/docker.py +++ b/pydra/environments/docker.py @@ -15,7 +15,7 @@ class Docker(base.Container): def execute(self, job: "Job[shell.Task]") -> dict[str, ty.Any]: docker_img = f"{self.image}:{self.tag}" # mounting all input locations - mounts, values = self.get_bindings(job=job, root=self.root) + mounts, arg_values = self.get_bindings(job=job, root=self.root) docker_args = [ "docker", @@ -32,7 +32,7 @@ def execute(self, job: "Job[shell.Task]") -> dict[str, ty.Any]: job.cache_dir.mkdir(exist_ok=True) values = base.execute( - docker_args + [docker_img] + job.task._command_args(values=values), + docker_args + [docker_img] + job.task._command_args(values=arg_values), ) output = dict(zip(keys, values)) if output["return_code"]: diff --git a/pydra/utils/typing.py b/pydra/utils/typing.py index b082a919f..811313817 100644 --- a/pydra/utils/typing.py +++ b/pydra/utils/typing.py @@ -527,7 +527,7 @@ def check_union(tp, pattern_args): except TypeError as e: reasons.append(e) else: - reasons = None + reasons = [] break if self.match_any_of_union and len(reasons) < len(tp_args): # Just need one of the union args to match @@ -1122,16 +1122,42 @@ def is_fileset_or_union(type_: type, allow_none: bool | None = None) -> bool: is_fileset : bool whether the type is a FileSet or a Union containing a FileSet """ + return is_subclass_or_union(type_, core.FileSet, allow_none=allow_none) + + +def is_subclass_or_union( + type_: type, reference: type, allow_none: bool | None = None +) -> bool: + """Check if the type is a subclass of given reference or a Union containing + that reference type + + Parameters + ---------- + type_ : type + the type to check + reference : type + the reference type to check whether the type is a sub-class of or not + allow_none : bool, optional + whether to allow None as a valid type, by default None. If None, then None + is not allowed at the outer layer, but is allowed within a Union + + Returns + ------- + bool + whether the type is a FileSet or a Union containing a FileSet + """ if type_ is None and allow_none: return True if is_union(type_): return any( - is_fileset_or_union(t, allow_none=allow_none or allow_none is None) + is_subclass_or_union( + t, reference, allow_none=allow_none or allow_none is None + ) for t in ty.get_args(type_) ) elif not inspect.isclass(type_): return False - return issubclass(type_, core.FileSet) + return issubclass(type_, reference) def is_type(*args: ty.Any) -> bool: diff --git a/pyproject.toml b/pyproject.toml index 72f4ccabd..89bcd8c08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ doc = [ "packaging", "pandas", "pandoc", - "pydra-mrtrix3 >=3.0.4a17", + "pydra-tasks-mrtrix3 >=3.1.0a1", "scipy", "sphinx", "sphinx-argparse", @@ -100,7 +100,7 @@ tutorial = [ "openneuro-py", "pandas", "psutil", - "pydra-mrtrix3 >=3.0.4a17", + "pydra-tasks-mrtrix3 >=3.1.0a1", "scipy", "sh", ]