Overview

Date: 2026-05-11

Time: 15:44

Overview

This is an example script demonstrating FTL2's remote SSH streaming execution with real-time progress tracking. It shows how to execute modules on remote hosts over SSH while receiving live event callbacks (progress updates, log messages) — covering single-host, multi-host, and auto-staging workflows. All examples target a local Docker container as the SSH endpoint.

Usage Patterns

Run the full example suite:


uv run python example_remote_streaming.py

Prerequisites: A Docker container with SSH access must be running (docker-compose up -d).

Four progressively complex examples:

1. Basic SSH streaming — Run a raw shell command and capture JSON events emitted on stderr:


stdout, stderr, rc, events = await host.run_streaming(
    'echo \'{"event": "log", ...}\' >&2; echo "output"',
    event_callback=on_event,
)

2. Remote bundle execution — Build a module into a bundle, stage it on the remote host, then execute with progress display:


bundle = build_bundle(module_path, dependencies=[])
bundle_path = await stage_bundle_remote(host, bundle)
result = await execute_remote_streaming(host, bundle_path, {"steps": 5}, event_callback=display.handle_event)

3. Multi-host parallel execution — Run bundles on multiple hosts concurrently, each with its own progress bar:


callback = display.make_callback(host_name)  # per-host progress
results = await asyncio.gather(*[run_on_host(name) for name in host_names])

4. Auto-staging — Combines staging and execution in one call:


result = await execute_remote_with_staging_streaming(host, bundle, {}, event_callback=display.handle_event)

API and Configuration

SSH connection settings (hardcoded for the Docker test container):

Key classes and functions:

Module-side event emission (available inside bundles):

Key Behaviors

Relationships