Package a Python source plugin¶
A Python source plugin packages importable node code and dependency declarations behind plugin.toml. The runtime resolves the plugin, imports its entry module in a worker, and registers its declared node types. It does not require a Rust dynamic library.
Prepare the plugin directory¶
The runnable example has two files:
Download the manifest and node module. The manifest is complete:
[plugin]
name = "docs-transform"
version = "0.1.0"
language = "python"
description = "A configured text transform loaded from Python source"
license = "MIT"
[python]
entry_module = "docs_transform"
node_types = ["DocsSourceTransform"]
requires = ["packaging==25.0"]
module_root = "."
entry_module is an import name, module_root is relative to the plugin directory, and node_types identifies registered names. requires contains Python dependency requirements; this fixture pins packaging==25.0 and actually imports it. Pin the dependencies and model assets that determine your production behavior; one pinned direct dependency does not freeze the full environment.
The constructor requires NodeConfig, reads the configured prefix, and rejects a bare node ID. initialize() acquires resources, process() returns a RuntimeData text value, and cleanup() releases resources when the node owns any. Register the class under the same node type named in the manifest.
Load it through a manifest¶
Use the MS2 native profile, a working uv installation on PATH, and the matching Python client source. This PowerShell excerpt selects that client for managed environments:
$env:REMOTEMEDIA_PYTHON_SRC = (Resolve-Path ../remotemedia-sdk/clients/python).Path
python examples/python/source_plugin.py
The complete launcher places the absolute directory path in the pipeline's plugins list, sets __python_version__ to 3.12, requests prefix SOURCE:, and waits up to 120 seconds for creation. Managed provisioning can take longer on a cold machine; the validation supervisor has a separate process deadline. The fixture checks SOURCE: HELLO, a distinct worker PID, and the installed dependency version.
The recorded run resolved a managed environment under the Windows user's .config/remotemedia/envs cache. The source loader passes the plugin dependency list, module search path, entry module and plugin identity into the worker environment. This path needs plugin resolution (loadable) and the native python-source-plugin feature. The earlier MS1 wheel and runner did not include it.
python_env.explicit_venv selects an already prepared environment instead of demonstrating managed provisioning. Use that deliberately for controlled environments; do not claim requires was provisioned merely because an explicit environment already contains its packages.
Package and publish deliberately¶
Ship the manifest and every imported module beneath the declared module root. Local directory loading is the executed fixture. The resolver also supports remote plugin specifications; a remote tag/archive publication and verification gate is a separate task. Check the staged files and the actual release archive before claiming a published package is complete.
remotemedia.runtime.load_plugin(...) is the native shared-library loader in the reviewed build. Do not pass this Python directory to it; use the pipeline plugins field.
Cleanup and deployment¶
The launcher closes the session in finally; the supervisor records child exit and fails if it must kill remaining children. Environment caches are reusable artifacts and are not removed as session cleanup. Avoid deleting a cache while another worker holds it.
For Entry-routed tools, the local Scaling harness uses this directory on the runner's filesystem. A distributed deployment must make the same package and compatible environment available on each eligible runner; a local absolute path is not a remote upload.
Source references: remotemedia-sdk-base/src/loadable/source_python.rs · remotemedia-sdk-base/src/loadable/resolver.rs (base revision; reviewed with local changes) · remotemedia-plugin-sdk/crates/py-env-manager/src/lib.rs (base revision; reviewed with local changes) · remotemedia-sdk/clients/python/remotemedia/core/multiprocessing/__init__.py · remotemedia-sdk/clients/python/remotemedia/core/multiprocessing/node.py