diff --git a/python/lsst/ctrl/mpexec/cli/opt/options.py b/python/lsst/ctrl/mpexec/cli/opt/options.py index 51a1549a..813d6758 100644 --- a/python/lsst/ctrl/mpexec/cli/opt/options.py +++ b/python/lsst/ctrl/mpexec/cli/opt/options.py @@ -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 @@ -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.""" ), )