monkey_wrench.generic.models._function module
- monkey_wrench.generic.models._function._import_monkey_wrench_function(function_path: str) Callable[[...], ReturnType][source]
Import a function (dynamically) from Monkey Wrench using its (string) identifier in the namespace.
Warning
Functions must belong to the Monkey Wrench package.
- Parameters:
function_path – The dot-delimited path of the function in the namespace excluding the leading
monkey_wrench. As an example to importmonkey_wrench.input_output.seviri.output_filename_from_product_id(), the function path must be set toinput_output.seviri.output_filename_from_product_id.- Returns:
The function that corresponds to the given function path.
- Raises:
ValueError – If
function_pathincludes any of the invalid items, e.g.$or:.ValueError – If
function_pathis a relative import path.TypeError – If
function_pathis imported successfully, but it does not point to a function.ImportError – If
function_pathcannot be imported successfully, e.g. it does not exist.
- monkey_wrench.generic.models._function.validate_function_path(path: str) Callable[[...], ReturnType][source]
- monkey_wrench.generic.models._function.Function
Type annotation and Pydantic validator to dynamically import a function from Monkey Wrench, given its path.
Note
The path must be a fully qualified namespace path to the function excluding the leading
monkey_wrench..alias of
Annotated[Callable[[…],ReturnType],BeforeValidator(func=validate_function_path, json_schema_input_type=PydanticUndefined)]
- monkey_wrench.generic.models._function.TransformFunction
Type annotation for a function that transforms items, e.g. before writing to or after reading from a file.
alias of
Annotated[Callable[[…],ReturnType],BeforeValidator(func=validate_function_path, json_schema_input_type=PydanticUndefined)] |Callable[[…],ReturnType]