teff.plugins¶
teff.plugins
¶
Folder-based plugin discovery for custom nodes and tools.
A plugin is any Python module that registers node types and/or tools via
the existing @node / @tool decorators. Loading a plugin simply
imports the file — registration happens as a side effect of the import,
so once loaded the new types are visible to validate / load_workflow
because both read from the shared registries.
Plugins are discovered from the plugins key of a workflow YAML (paths
to .py files or directories) and, by default, from a plugins/
folder next to the workflow file::
plugins:
- ./custom_nodes.py
- ./vendor/tools
steps:
- id: greet
type: my_custom_node # registered by custom_nodes.py
Functions:
| Name | Description |
|---|---|
load_plugin_dir |
Import every |
load_plugin_file |
Import a single plugin |
load_plugins |
Load plugins from explicit entries plus a default folder. |
load_plugins_from_document |
Load plugins declared in a workflow document. |
reset_plugins |
Clear the import cache (used by tests). |
load_plugin_dir
¶
load_plugin_dir(path)
Import every *.py file under path (non-recursive).
Files starting with _ are skipped so __init__.py and helpers
are ignored. Returns the list of imported file paths.
Source code in teff/plugins.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
load_plugin_file
¶
load_plugin_file(path)
Import a single plugin .py file (idempotent per path).
Source code in teff/plugins.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
load_plugins
¶
load_plugins(entries, base_dir='.', default_folder='plugins')
Load plugins from explicit entries plus a default folder.
Each entry is a path — relative to base_dir, or absolute — to a
.py file or a directory of .py files. The default_folder
(default "plugins") is always loaded when it exists, so a user
can drop a plugins/ folder next to a workflow with no YAML
changes.
Returns the list of loaded file paths.
Source code in teff/plugins.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
load_plugins_from_document
¶
load_plugins_from_document(data, base_dir)
Load plugins declared in a workflow document.
Reads data["plugins"] (files/folders) and data["plugins_folder"]
(a single folder, defaulting to "plugins") and loads them relative
to base_dir.
Source code in teff/plugins.py
108 109 110 111 112 113 114 115 116 | |
reset_plugins
¶
reset_plugins()
Clear the import cache (used by tests).
Source code in teff/plugins.py
119 120 121 | |