Skip to content

Commit e469555

Browse files
committed
fixing xor and allowed_val checks
1 parent 1b7b4c8 commit e469555

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pydra/engine/specs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def check_fields_input_spec(self):
135135

136136
# checking if fields meet the xor and requires are
137137
if "xor" in mdata:
138-
if [el for el in mdata["xor"] if el in names]:
138+
if [el for el in mdata["xor"] if (el in names and el != fld.name)]:
139139
raise AttributeError(
140140
f"{fld.name} is mutually exclusive with {mdata['xor']}"
141141
)
@@ -473,6 +473,8 @@ def _check_requires(self, fld, inputs):
473473
""" checking if all fields from the requires and template are set in the input
474474
if requires is a list of list, checking if at least one list has all elements set
475475
"""
476+
from .helpers import ensure_list
477+
476478
if "requires" in fld.metadata:
477479
# if requires is a list of list it is treated as el[0] OR el[1] OR...
478480
if all([isinstance(el, list) for el in fld.metadata["requires"]]):
@@ -512,7 +514,7 @@ def _check_requires(self, fld, inputs):
512514
required_found = False
513515
break
514516
elif isinstance(inp, tuple): # (name, allowed values)
515-
inp, allowed_val = inp
517+
inp, allowed_val = inp[0], ensure_list(inp[1])
516518
if not hasattr(inputs, inp):
517519
raise Exception(
518520
f"{inp} is not a valid input field, can't be used in requires"

0 commit comments

Comments
 (0)