Extending canesm-processor#
Register Module#
- canproc.register_module(module, prefix: str, func_factory: Callable | None = None, check_lookup: Callable | None = None)#
Register a module so functions can be serialized and ran from that module.
- Parameters:
module (
module) – A new module to be registeredprefix (
str) – prefix for the modulefunc_factory (
Callable | None, optional) – If your module has function with wrappers, partials it may be necessary to write a custom function_factory to dispatch a function from string. If this is set func_factory(name) will be called for function dispatch, by defaultlambda name: getattr(module, name.split(".")[1])check_lookup (
Callable | None, optional) – Option function to use for matching modules with prefixes. By defaultlambda x: prefix == x
Examples
>>> from canproc import register_module, DAG >>> from mypackage import mymodule >>> register_module(mymodule, 'mymod') >>> DAG(dag=[DAGProcess(name='data', function='mymod.myfunction', args=[1,2,3])], output='data')