MirrorNeuron Python SDK
Project description
MirrorNeuron Python SDK
Python client and workflow-bundle helpers for MirrorNeuron.
The SDK provides the gRPC client used by the CLI and API, plus decorators and bundle generation utilities for Python-defined workflows.
Features
- gRPC
Clientwrapper for job and runtime operations. - Decorators for defining workflow and agent functions in Python.
- Bundle generation from decorated workflow classes.
- Runner, retry, and backpressure configuration helpers.
- Environment-based client configuration for local tools and services.
Tech Stack
| Area | Tooling |
|---|---|
| Runtime | Python 3.9+ |
| Transport | gRPC |
| Protocol | Protobuf |
| Packaging | setuptools with setuptools-scm |
Prerequisites
- Python 3.9 or newer.
- A running MirrorNeuron core for client calls.
- Generated protocol modules included with the package.
Installation
The released-package installer installs this package automatically.
Standalone install:
pip install mirrorneuron-python-sdk
Developer install:
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
Configuration
Constructor arguments take precedence over environment variables.
| Variable | Default | Description |
|---|---|---|
MN_GRPC_TARGET |
localhost:50051 |
Core gRPC target when Client(target=...) is omitted. |
MN_CORE_GRPC_TARGET |
unset | Fallback core gRPC target. |
MN_GRPC_TIMEOUT_SECONDS |
10 |
Per-RPC timeout. Use 0 or none to disable. |
MN_GRPC_AUTH_TOKEN |
unset | Optional bearer metadata. |
MN_SDK_LOG_PATH |
~/.mn/logs/sdk.log |
SDK log file path. |
MN_LOG_LEVEL |
package default | Log level used by shared logging setup. |
MN_LOG_MAX_BYTES |
package default | Rotating log size limit. |
MN_LOG_BACKUP_COUNT |
package default | Rotating log backup count. |
Client Usage
from mn_sdk import Client
client = Client(target="localhost:50051")
job_id = client.submit_job(manifest_json="...", payloads={})
print(client.get_job(job_id))
Common client methods:
| Method | Description |
|---|---|
submit_job(manifest_json, payloads) |
Submit a job from a manifest string and payload map. |
get_job(job_id) |
Fetch one job. |
list_jobs(limit=0, include_terminal=True) |
List jobs. |
cancel_job(job_id) |
Cancel a job. |
pause_job(job_id) |
Pause a job. |
resume_job(job_id) |
Resume a job. |
clear_jobs() |
Clear job history. |
get_system_summary() |
Fetch runtime summary. |
remove_node(node_name) |
Remove a node from the runtime view. |
stream_events(job_id) |
Stream job events. |
Python Workflow Example
from pathlib import Path
from mn_sdk import RunnerConfig, agent, build_bundle, workflow
@agent.defn(type="map", runner=RunnerConfig.host_local())
def normalize_text(value: str) -> str:
return value.strip().lower()
@workflow.defn(name="TextWorkflow")
class TextWorkflow:
@workflow.run
def run(self):
normalize_text(" Example ")
bundle_dir = build_bundle(TextWorkflow, Path("/tmp/text-workflow"))
print(bundle_dir)
The generated bundle can be submitted with the CLI:
mn run /tmp/text-workflow
Public API
The package exports:
Clientagentworkflowbuild_bundleBundleCompileErrorRunnerConfigRetryPolicyBackpressurePolicy
Testing
python3 -m pytest -q
Deployment
Applications can depend on mirrorneuron-python-sdk directly when they need to submit jobs or generate bundles programmatically. Runtime deployment still requires the MirrorNeuron core and its backing services.
Troubleshooting
| Symptom | Check |
|---|---|
| gRPC connection fails | Confirm the core is running and MN_GRPC_TARGET points to it. |
| Calls hang longer than expected | Set MN_GRPC_TIMEOUT_SECONDS. |
| Authenticated gateway rejects calls | Set MN_GRPC_AUTH_TOKEN. |
| Bundle generation fails | Check that the workflow class is decorated and that referenced agent calls are statically discoverable. |
Contributing
Keep SDK changes backward-compatible with the CLI and API. Add focused tests for client calls, bundle generation, and configuration behavior.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mirrorneuron_python_sdk-1.1.0.tar.gz.
File metadata
- Download URL: mirrorneuron_python_sdk-1.1.0.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ad6125d6b6fa6432289fbb770451bc9a83aa00c3754537ff08ee6ba97c41f9
|
|
| MD5 |
a4590ac81edc6a8268650515ac2f1363
|
|
| BLAKE2b-256 |
d09790078d8a891ed9725df8f819418ce8a8501d06ad7eb95d9f9da69f50ae42
|
Provenance
The following attestation bundles were made for mirrorneuron_python_sdk-1.1.0.tar.gz:
Publisher:
release.yml on MirrorNeuronLab/mn-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mirrorneuron_python_sdk-1.1.0.tar.gz -
Subject digest:
55ad6125d6b6fa6432289fbb770451bc9a83aa00c3754537ff08ee6ba97c41f9 - Sigstore transparency entry: 1439840263
- Sigstore integration time:
-
Permalink:
MirrorNeuronLab/mn-python-sdk@ae97eb168f56788f9016bd8b3b8755478c99ed45 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/MirrorNeuronLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ae97eb168f56788f9016bd8b3b8755478c99ed45 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mirrorneuron_python_sdk-1.1.0-py3-none-any.whl.
File metadata
- Download URL: mirrorneuron_python_sdk-1.1.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6a458d5e9e929fdc4c6babc5343ef67a10afb05613454825e880af35208c4ab
|
|
| MD5 |
09b86740724aa041106ae9cba4cf2194
|
|
| BLAKE2b-256 |
a22614dcdb2c560c130938e0ccb4ee3b503dd368ebc0fdb9e312ec9df8026698
|
Provenance
The following attestation bundles were made for mirrorneuron_python_sdk-1.1.0-py3-none-any.whl:
Publisher:
release.yml on MirrorNeuronLab/mn-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mirrorneuron_python_sdk-1.1.0-py3-none-any.whl -
Subject digest:
d6a458d5e9e929fdc4c6babc5343ef67a10afb05613454825e880af35208c4ab - Sigstore transparency entry: 1439840281
- Sigstore integration time:
-
Permalink:
MirrorNeuronLab/mn-python-sdk@ae97eb168f56788f9016bd8b3b8755478c99ed45 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/MirrorNeuronLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ae97eb168f56788f9016bd8b3b8755478c99ed45 -
Trigger Event:
push
-
Statement type: