nodify.nodify_module

nodify.nodify_module(module: ~types.ModuleType, node_class: ~typing.Type[~nodify.node.Node] = <class 'nodify.node.Node'>) ModuleType[source]

Returns a copy of a module where all functions are replaced with nodes.

This new nodified module contains only nodes (coming from functions or classes). The rest of variables are not copied. In fact, the new module uses the variables from the original module.

Also, some functions might not be convertable to nodes and therefore won’t be found in the new module.

For each module that is found while traversing, its __nodify__ function is called if it exists.

Parameters:
  • module (ModuleType) – The module to nodify.

  • node_class (Type[Node], optional) – The class from which the created nodes will inherit, by default Node. This can be useful for example to convert to workflows, if you pass the Workflow class.

Returns:

A new module with all functions replaced with nodes.

Return type:

ModuleType