Skip to content

Commit

Permalink
raise exception on validate failure
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed Apr 12, 2024
1 parent 411dea2 commit ab47d5d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fabrictestbed_extensions/fablib/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2614,10 +2614,13 @@ def _is_modify(self) -> bool:
else:
return True

def validate(self) -> Tuple[bool, Dict[str, str]]:
def validate(self, raise_exception: bool = True) -> Tuple[bool, Dict[str, str]]:
"""
Validate the slice w.r.t available resources before submission
:param raise_exception: raise exception if validation fails
:type raise_exception: bool
:return: Tuple indicating status for validation and dictionary of the errors corresponding to
each requested node
:rtype: Tuple[bool, Dict[str, str]]
Expand All @@ -2629,5 +2632,10 @@ def validate(self) -> Tuple[bool, Dict[str, str]]:
node=n, allocated=allocated
)
if not status:
errors[n.get_name()] = error
if raise_exception:
print(f"{n.get_name()}: {error}")
else:
errors[n.get_name()] = error
if raise_exception:
raise Exception("Slice validation failed!")
return len(errors) == 0, errors

0 comments on commit ab47d5d

Please sign in to comment.