decorators
generics.decorators
Decorator utilities for CaML.
This module provides decorators for various functionalities in CaML.
Functions
| Name | Description |
|---|---|
| experimental | Decorator to mark functions or classes as experimental. |
| narrate | Decorator to log the execution of a function or method. |
| timer | Decorator to measure the execution time of a function or method, logged at DEBUG level. |
experimental
generics.decorators.experimental(obj)Decorator to mark functions or classes as experimental.
This decorator will show a warning when the decorated object is first used, indicating that it is experimental and may change in future versions.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| obj | Callable | The class or function to mark as experimental | required |
Returns
| Name | Type | Description |
|---|---|---|
| Callable | The decorated class or function |
narrate
generics.decorators.narrate(
preamble=None,
epilogue=':white_check_mark: Completed.',
)Decorator to log the execution of a function or method.
This decorator will log a pre-execution (preamble) message and a post-execution (epilogue) message.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| preamble | str | The message to log before the function or method execution. | None |
| epilogue | str | The message to log after the function or method execution. | ':white_check_mark: Completed.' |
Returns
| Name | Type | Description |
|---|---|---|
| Callable | The decorated class or function |
timer
generics.decorators.timer(operation_name=None)Decorator to measure the execution time of a function or method, logged at DEBUG level.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| operation_name | str | None | The name of the operation to be timed. If None, the name of the function or method will be used. | None |
Returns
| Name | Type | Description |
|---|---|---|
| Callable | The decorated function or method |