Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pydra/environments/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]:
Expand Down
32 changes: 29 additions & 3 deletions pydra/utils/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ doc = [
"packaging",
"pandas",
"pandoc",
"pydra-mrtrix3 >=3.0.4a17",
"pydra-tasks-mrtrix3 >=3.1.0a1",
"scipy",
"sphinx",
"sphinx-argparse",
Expand Down Expand Up @@ -100,7 +100,7 @@ tutorial = [
"openneuro-py",
"pandas",
"psutil",
"pydra-mrtrix3 >=3.0.4a17",
"pydra-tasks-mrtrix3 >=3.1.0a1",
"scipy",
"sh",
]
Expand Down
Loading