datumaro.util.scope#
Functions
|
|
|
|
|
|
|
A function decorator, which allows to do actions with the current scope, such as registering error and exit callbacks and context managers. |
Classes
|
A context manager that allows to register error and exit callbacks. |
- class datumaro.util.scope.Scope[source]#
Bases:
object
A context manager that allows to register error and exit callbacks.
- on_error_do(callback: Callable, *args, kwargs: Dict[str, Any] | None = None, ignore_errors: bool = False)[source]#
Registers a function to be called on scope exit because of an error.
If ignore_errors is True, the errors from this function call will be ignored.
- on_exit_do(callback: Callable, *args, kwargs: Dict[str, Any] | None = None, ignore_errors: bool = False)[source]#
Registers a function to be called on scope exit.
- add(cm: ContextManager[T]) T [source]#
Enters a context manager and adds it to the exit stack.
Returns: cm.__enter__() result
- datumaro.util.scope.scoped(func, arg_name=None)[source]#
A function decorator, which allows to do actions with the current scope, such as registering error and exit callbacks and context managers.
- datumaro.util.scope.scope_add(cm: ContextManager[T]) T [source]#