Python SDK
Programmatic API for Python workflows using the synfire package.
Installation
Install Synfire to use the SDK:
pip install synfireQuick Start
from synfire import Client
# Initialize the client
client = Client()
# Search for models
results = client.search("lif", tags=["single-neuron"])
# Download a model
release = client.pull("pabogdan/lifneuron:1.0.0")
# Load the NIR model
graph = release.load()Authentication
The SDK supports multiple authentication methods:
# Option 1: Environment variable (recommended for CI/CD)
# Set SYNFIRE_TOKEN in your environment
# Option 2: Explicit token
client = Client(token="synfire_your_token_here")
# Option 3: Use CLI authentication
# Run 'synfire login' first, then the SDK will use stored credentials
client = Client()Client API Reference
Client.search()
Search for models in the registry.
results = client.search(
query="lif",
tags=["single-neuron"], # Optional: filter by tags
limit=20, # Optional: max results
)Client.pull()
Download a model to a local directory.
# Pull latest version
release = client.pull("pabogdan/lifneuron")
# Pull specific version
release = client.pull("pabogdan/lifneuron", version="1.0.0")
# Pull to specific directory
release = client.pull("pabogdan/lifneuron", output_dir="./models")Client.publish()
Publish a model to the registry.
This example target requires ownership of the repository.
from pathlib import Path
client.publish(
repo="pabogdan/lifneuron",
version="1.0.0",
model_path=Path("./model.nir"),
card_path=Path("./nir-card.json"),
notes_path=Path("./RELEASE_NOTES.md"), # Optional
)Working with NIR Models
Synfire works seamlessly with the NIR library:
import nir
from synfire import Client
client = Client()
# Download and load a model
release = client.pull("pabogdan/lifneuron:1.0.0")
graph = release.load()
# Inspect the model
print(f"Nodes: {list(graph.nodes.keys())}")
print(f"Edges: {graph.edges}")