Skip to main content

Python client library for the Spark Fuse GPU compute API

Project description

Spark Fuse Messenger

Python client and CLI for the Spark Fuse on-demand GPU compute API.

Submit Docker-image jobs to cloud GPUs, stream live logs, and pull outputs back from ShareSync — all from Python or the command line.

Requirements

  • Python 3.12+
  • uv (pip install uv)
  • A Spark Fuse account with API credentials

API reference

This client implements the Spark Fuse REST API. The API is documented in spark-fuse-api-v119.md, a file provided by Spark Cloud Studio to its customers. That document is not redistributed in this repo. If you want to reference it locally, place your own copy in the project root.

Setup

git clone https://github.com/VFXGuru/spark-fuse-messenger
cd spark-fuse-messenger
uv sync

Copy .env.example to .env and fill in your credentials:

SPARK_HOST=https://api.prod.aapse1.sparkcloud.studio
SPARK_EMAIL=you@yourcompany.com
SPARK_PASSWORD=your-password

.env is gitignored and never committed.

Activate the venv or prefix every command with uv run:

.venv\Scripts\activate        # Windows
source .venv/bin/activate     # macOS / Linux

CLI commands

# Verify credentials (free)
spark-fuse login

# List available GPU SKUs (free)
spark-fuse skus

# Cost estimate — rate only, or with runtime (free)
spark-fuse estimate g4dn.xlarge --runtime 3600

# Submit a job
spark-fuse submit --image alpine:3 --command echo --command hello --instance-type g4dn.xlarge

# Submit with a local input directory (auto tar+upload)
spark-fuse submit --image pytorch/pytorch:2.7.1-cuda12.8-cudnn9-runtime \
  --command python3 --command /input/run.py \
  --instance-type g7e.2xlarge --input-dir ./my-scripts

# Poll status
spark-fuse status <job-id>

# List all jobs (optional tag filters)
spark-fuse list
spark-fuse list --tag ci --tag training          # AND filter
spark-fuse list --tags-any "ci,staging"          # OR filter

# Stream live logs (connect immediately after submit — no replay)
spark-fuse logs <job-id>

# Cancel (idempotent)
spark-fuse cancel <job-id>

# Download all output files
spark-fuse download <job-id> ./outputs

# Persistent-compute sessions: pre-warm one instance and run jobs back to back (§13)
spark-fuse instance prepare g7e.2xlarge --hold-seconds 1800   # prints a handle
spark-fuse instance status <handle>                           # poll until 'ready'
spark-fuse instance release <handle>                          # tear down

Submit jobs onto a prepared session by passing the handle: spark-fuse submit ... --instance-handle <handle> (or instance_handle= on client.submit). Each job lands on that same warm instance with no cold start.

Python API

from spark_fuse import SparkFuseClient

with SparkFuseClient(host="...", email="...", password="...") as client:
    client.login()

    resp = client.submit(
        image="alpine:3",
        command=["echo", "hello"],
        instance_type="g4dn.xlarge",
    )
    job_id = resp.job_id

    for event in client.stream_logs(job_id):
        print(event)

    job = client.get_job(job_id)
    print(job.status, job.exit_code)

Running tests

All tests mock HTTP — no network calls required:

uv run pytest -v

Project structure

src/spark_fuse/
├── client.py      — SparkFuseClient (all API methods)
├── auth.py        — login + token management
├── sharesync.py   — WebDAV: tar+upload, PROPFIND, streaming download
├── logs.py        — SSE log streaming
├── errors.py      — typed exceptions
├── models.py      — dataclasses + enums (JobStatus, ErrorCode, …)
└── cli.py         — Typer CLI

tests/             — unit tests (HTTP mocked)

License

MIT — Copyright (c) 2026 VFXGuru

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spark_fuse_messenger-0.3.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spark_fuse_messenger-0.3.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file spark_fuse_messenger-0.3.0.tar.gz.

File metadata

  • Download URL: spark_fuse_messenger-0.3.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for spark_fuse_messenger-0.3.0.tar.gz
Algorithm Hash digest
SHA256 11e6fbdde570a37cbb7d82371fc335cdbe8d38692271844fd3d2542b6153a21d
MD5 61ae9a3ff2c3263362c277d6a23895be
BLAKE2b-256 ce7e71654ad6e507a69784ca7105ccf4b51f8d795245483d22282faa57c66fef

See more details on using hashes here.

File details

Details for the file spark_fuse_messenger-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spark_fuse_messenger-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7238f364cb5bb082a5fc7a10653ebc4e37edf0447177c0c68e4478cea53ba84e
MD5 f9e5b7348356643db3e3ab00c51f2b4f
BLAKE2b-256 cf9eb773ea267b5ed68fb2df9ebc8c17a8acb2c372537733eb48fcc8a318f45c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page