teff.node.registry¶
teff.node.registry
¶
Node registry and decorator for registering node types.
Classes:
| Name | Description |
|---|---|
NodeRegistry |
Registry mapping node type names to factory functions. |
Functions:
| Name | Description |
|---|---|
make_function_node |
Wrap an async (or sync) function into a :class: |
node |
Decorator that registers an async function as a node type. |
NodeRegistry
¶
Registry mapping node type names to factory functions.
Used by the YAML loader and pipeline compiler to instantiate nodes by their string type identifier.
Methods:
| Name | Description |
|---|---|
copy |
Return a shallow copy with the same factory registrations. |
create |
Create a node instance by type name. |
list |
Return all registered node type names. |
register |
Register a node factory under a type name. |
Source code in teff/node/registry.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
copy
¶
copy()
Return a shallow copy with the same factory registrations.
Source code in teff/node/registry.py
52 53 54 55 56 | |
create
¶
create(name, config=None, **kwargs)
Create a node instance by type name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered node type name. |
required |
config
|
dict | None
|
Optional configuration dict (backward-compatible). |
None
|
**kwargs
|
Any
|
Additional keyword arguments merged into config. |
{}
|
Returns:
| Type | Description |
|---|---|
Node
|
A Node instance. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the type name is not registered
(also a |
Source code in teff/node/registry.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
list
¶
list()
Return all registered node type names.
Source code in teff/node/registry.py
48 49 50 | |
register
¶
register(name, factory)
Register a node factory under a type name.
Source code in teff/node/registry.py
23 24 25 | |
make_function_node
¶
make_function_node(fn, type_name=None)
Wrap an async (or sync) function into a :class:Node instance.
The function is called as fn(ctx, state) and must return a dict of
state updates or a :class:~teff.node.command.Command. Sync functions
are supported. type_name sets the node's type (defaults to the
function's __name__).
This is the building block behind Flow.step(fn); it does not
register the node type in the registry.
Source code in teff/node/registry.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
node
¶
node(node_name, config=None)
Decorator that registers an async function as a node type.
The decorated function receives (ctx, state) or (ctx, config, state)
when a typed config dataclass is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_name
|
str
|
Type name to register under. |
required |
config
|
type[Any] | None
|
Optional dataclass type for typed config parsing. |
None
|
Source code in teff/node/registry.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |