Skip to content

Connect to Scaling from Python

Use remotemedia.control.attach() to control a live distributed session through Scaling Entry. Entry resolves node addresses to runner partitions and forwards control operations. Python uses the same control attach surface as a compatible standalone gRPC host.

Before you attach

Use the checkout control environment. The published 0.2.0 client lacks token= and cannot run this authenticated example unchanged.

You need a running Entry deployment, its admin gRPC address, a backend token when authentication is enabled, and an existing session. The session can be addressed by its internal ID or by <pipeline>/<session key>.

Attaching does not deploy a pipeline, join a media participant, or start a session. A token for a media client is not the backend token required by this admin control interface.

Run a complete local control walkthrough

The harness starts an authenticated Entry and one real runner. Supply an existing compatible Scaling build directory containing remotemedia-scaling-entry.exe and remotemedia-scaling-runner.exe:

.venv-control/Scripts/python.exe examples/scaling/run.py --bin-dir C:/path/to/scaling-build

Expected output:

hello through Entry
PASS: authenticated Entry control, runner echo, admission, and teardown. Evidence: .../result.json

The harness chooses free ports, generates an ephemeral Ed25519 key, and signs separate short-lived backend and client tokens. It verifies an unauthenticated admin request returns 401, deploys the echo manifest, admits a client to create the session, subscribes to echo.out, then publishes to echo.in through Entry. Deployment's path name must match metadata.name in the manifest.

Tokens are not printed. The private key stays in memory; the public key, server logs, and binary hashes go in .run/scaling/<run>/. The harness deletes its session and pipeline, then stops and reaps only the servers it started. This plaintext setup is for local evaluation; existing deployments should supply appropriate channel credentials.

The check covers control routing through Entry to a runner and client admission. It does not establish WebRTC media negotiation, multi-runner placement, failover, or model performance. Server binary commits are unverified; their hashes are recorded in the validation report.

Observe a node

The complete remote control example reads REMOTEMEDIA_CONTROL_ADDRESS, REMOTEMEDIA_SESSION_ID, and optionally REMOTEMEDIA_CONTROL_TOKEN. REMOTEMEDIA_TAP selects an output address and defaults to echo.out. Set these for your existing deployment, then run:

python examples/python/remote_control.py

It waits up to 30 seconds for one new tapped output and then detaches. Produce input through the running application after the subscription opens. No output within that window raises a timeout; it does not establish that the session is broken.

The core operation is:

from remotemedia.control import attach

async def observe(address, session_id, token):
    async with attach(address, session_id=session_id, token=token) as ctrl:
        tap = await ctrl.subscribe("echo.out")
        try:
            async for item in tap:
                print(item.text)
        finally:
            await tap.aclose()

Use host:port for the gRPC address, not an HTTP URL. attach() accepts gRPC channel credentials for a secured deployment. The complete example targets a local/private plaintext admin listener; adapt transport credentials to your deployment.

Separate deployment, admission, and control

Operation Interface Who uses it?
Deploy or replace a named pipeline Admin HTTP PUT /pipelines/{name} with {"manifest": ..., "warm": 0} Backend
Join a session Public HTTP POST /join or Entry signaling Client with a token identifying pipeline/session/member
Connect participant media Runner signal_url, admission ticket, then WebRTC negotiation Media client
Tap/publish/intercept/call node RPC Admin gRPC PipelineControl through Python attach() Backend
Inspect placement Admin HTTP /sessions/{id}/placement and event stream Operator/backend

The join response supplies runner signaling information and a ticket; it is not itself a media stream. Clients do not submit manifests in joins. Continue with the executed Python WebRTC guide for negotiation, audio delivery and cleanup. The example composes HTTP, control and media APIs; no dedicated ScalingClient facade is assumed.

Lifecycle and limits

Leaving async with attach(...) closes that control attach. It does not end the distributed session. Session/member termination uses separate administration operations.

Entry caps relayed tap traffic per attach; the reviewed default is 1 MiB/s, with excess tap frames dropped and counted. Taps support observation and do not promise lossless media delivery or replay. Node movement, runner loss, and recovery depend on placement/state-class rules; reconnecting a control client is not arbitrary checkpoint restoration.

Continue with control and RPC for shared operations and the API map for their entry points.