Skip to content

Commit ad78e34

Browse files
committed
fixing issues with attr.NOTHING vs None
1 parent bd46025 commit ad78e34

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

pydra/engine/helpers_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def template_update(inputs, map_copyfiles=None):
494494
fields = attr_fields(inputs)
495495
# TODO: Create a dependency graph first and then traverse it
496496
for fld in fields:
497-
if getattr(inputs, fld.name) is not None:
497+
if getattr(inputs, fld.name) is not attr.NOTHING:
498498
continue
499499
if fld.metadata.get("output_file_template"):
500500
if fld.type is str:

pydra/engine/specs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ def _field_metadata(self, fld, inputs, output_dir):
373373
class ContainerSpec(ShellSpec):
374374
"""Refine the generic command-line specification to container execution."""
375375

376-
image: ty.Union[File, str] = attr.ib(metadata={"help_string": "image"})
376+
image: ty.Union[File, str] = attr.ib(
377+
metadata={"help_string": "image", "mandatory": True}
378+
)
377379
"""The image to be containerized."""
378380
container: ty.Union[File, str, None] = attr.ib(
379381
metadata={"help_string": "container"}

pydra/engine/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def container_check(self, container_type):
463463
raise AttributeError(
464464
f"Container type should be {container_type}, but {self.inputs.container} given"
465465
)
466-
if self.inputs.image is None:
466+
if self.inputs.image is attr.NOTHING:
467467
raise AttributeError("Container image is not specified")
468468

469469
def bind_paths(self, ind=None):

pydra/engine/tests/test_shelltask.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ def test_shell_cmd_inputspec_3c(plugin, results_function):
458458
"text",
459459
attr.ib(
460460
type=str,
461+
default=None,
461462
metadata={"position": 1, "help_string": "text", "mandatory": False},
462463
),
463464
)

pydra/engine/tests/test_task.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,9 @@ def test_shell_cmd(tmpdir):
352352

353353
def test_container_cmds(tmpdir):
354354
containy = DockerTask(name="containy", executable="pwd")
355-
with pytest.raises(AttributeError):
356-
containy.cmdline
357-
containy.inputs.container = "docker"
358-
with pytest.raises(AttributeError):
355+
with pytest.raises(AttributeError) as excinfo:
359356
containy.cmdline
357+
assert "not specified" in str(excinfo.value)
360358
containy.inputs.image = "busybox"
361359
assert containy.cmdline
362360

0 commit comments

Comments
 (0)