Skip to content

Commit

Permalink
fixing xor and allowed_val checks
Browse files Browse the repository at this point in the history
  • Loading branch information
djarecka committed Sep 21, 2020
1 parent 1b7b4c8 commit e469555
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pydra/engine/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def check_fields_input_spec(self):

# checking if fields meet the xor and requires are
if "xor" in mdata:
if [el for el in mdata["xor"] if el in names]:
if [el for el in mdata["xor"] if (el in names and el != fld.name)]:
raise AttributeError(
f"{fld.name} is mutually exclusive with {mdata['xor']}"
)
Expand Down Expand Up @@ -473,6 +473,8 @@ def _check_requires(self, fld, inputs):
""" checking if all fields from the requires and template are set in the input
if requires is a list of list, checking if at least one list has all elements set
"""
from .helpers import ensure_list

if "requires" in fld.metadata:
# if requires is a list of list it is treated as el[0] OR el[1] OR...
if all([isinstance(el, list) for el in fld.metadata["requires"]]):
Expand Down Expand Up @@ -512,7 +514,7 @@ def _check_requires(self, fld, inputs):
required_found = False
break
elif isinstance(inp, tuple): # (name, allowed values)
inp, allowed_val = inp
inp, allowed_val = inp[0], ensure_list(inp[1])
if not hasattr(inputs, inp):
raise Exception(
f"{inp} is not a valid input field, can't be used in requires"
Expand Down

0 comments on commit e469555

Please sign in to comment.