Skip to content

Commit

Permalink
Propogate new mocked-failures functionality through pipetask.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Mar 27, 2024
1 parent 85ef81f commit ed8df98
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,19 +478,25 @@ def parse_mock_failure(
value : `~collections.abc.Iterable` [`str`] or `None`
Value from option.
"""
from lsst.pipe.base.tests.mocks import ForcedFailure

result: dict[str, tuple[str, type[Exception] | None]] = {}
if value is None:
return result
for entry in value:
try:
task_label, error_type_name, where = entry.split(":", 2)
task_label, error_type_name, where, *rest = entry.split(":")
if rest:
(memory_required,) = rest
else:
memory_required = None
except ValueError:
raise click.UsageError(
f"Invalid value for --mock-failure option: {entry!r}; "
"expected a string of the form 'task:error:where'."
"expected a string of the form 'task:error:where[:mem]'."
) from None
error_type = doImportType(error_type_name) if error_type_name else None
result[task_label] = (where, error_type)
result[task_label] = ForcedFailure(where, error_type, memory_required)
return result


Expand All @@ -502,11 +508,15 @@ def parse_mock_failure(
multiple=True,
help=unwrap(
"""Specifications for tasks that should be configured to fail
when mocking execution. This is a colon-separated 3-tuple, where the
first entry the task label, the second the fully-qualified exception
type (empty for ValueError, and the third a string (which typically
needs to be quoted to be passed as one argument value by the shell) of
the form passed to --where, indicating which data IDs should fail."""
when mocking execution. This is a colon-separated 3-tuple or 4-tuple,
where the first entry the task label, the second the fully-qualified
exception type (empty for ValueError, and the third a string (which
typically needs to be quoted to be passed as one argument value by the
shell) of the form passed to --where, indicating which data IDs should
fail. The final optional term is a memory threshold (with units
recognized by astropy), which will cause the error to only occur if
the available memory (according to ExecutionResources.max_mem) is less
than this value."""
),
)

Expand Down

0 comments on commit ed8df98

Please sign in to comment.