Skip to content

Commit

Permalink
update: raise for invalid element selector in api.functions.run
Browse files Browse the repository at this point in the history
  • Loading branch information
synchon committed Dec 18, 2024
1 parent 7e12e23 commit c0ee8d1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions junifer/api/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def run(
------
ValueError
If ``workdir.cleanup=False`` when ``len(elements) > 1``.
RuntimeError
If invalid element selectors are found.
"""
# Conditional to handle workdir config
Expand Down Expand Up @@ -208,10 +210,22 @@ def run(
# Fit elements
with datagrabber_object:
if elements is not None:
for t_element in datagrabber_object.filter(
elements # type: ignore
):
# Keep track of valid selectors
valid_elements = []
for t_element in datagrabber_object.filter(elements):
valid_elements.append(t_element)
mc.fit(datagrabber_object[t_element])
# Compute invalid selectors
invalid_elements = set(elements) - set(valid_elements)
# Report if invalid selectors are found
if invalid_elements:
raise_error(
msg=(
"The following element selectors are invalid:\n"
f"{invalid_elements}"
),
klass=RuntimeError,
)
else:
for t_element in datagrabber_object:
mc.fit(datagrabber_object[t_element])
Expand Down

0 comments on commit c0ee8d1

Please sign in to comment.