Skip to main content

ska-src-ef-broker-client

Client library for the SRCNet computing broker: submit jobs, watch them, fetch their logs.

One dependency (requests). Installing the broker service instead would pull FastAPI, SQLAlchemy, Alembic, pika and the HTCondor bindings onto a machine that only wants to submit a job.

pip install ska-src-ef-broker-client

Run something

from ska_src_ef_broker_client import Broker

broker = Broker("https://broker.example.org", token=my_access_token)

job = broker.run("echo hello", image="registry.example.org/tools/app:1")
job.wait()                 # blocks until terminal, returns the concise status
print(job.state)           # COMPLETE
print(job.logs())

You never name a site: you say what to run and which data it needs, and the broker decides where that can happen.

Follow the data

Passing Rucio data identifiers makes the broker resolve where they live and restrict placement to the sites holding them:

job = broker.run(
    "./analyse.sh /srcnet/input",
    image="registry.example.org/tools/analysis:2",
    dids=["SKA-Mid.integration:EB-1234.product-abcd"],
    input_url="dav://storm.example.org/sa/inputs",
)

/srcnet/input exists only when the job declares an input area — run() omits --input otherwise rather than binding a path you never asked for.

A Dask cluster

The broker starts a scheduler and workers as sibling tasks on one site and hands your command the rendezvous file:

broker.run_dask(
    "python analysis.py",         # your code is the cluster's client
    image="registry.example.org/tools/analysis-dask:1",
    workers=4,
).wait(timeout=3600)

Your image runs all three roles, so it has to contain Dask itself — the scheduler and workers are dask scheduler / dask worker in your image, and the workers execute your code, so they need your libraries too. One layer is enough:

FROM registry.example.org/tools/analysis:1
RUN pip install --no-cache-dir "dask[array,distributed]==2026.7.1"

An image without Dask fails fast with a message naming it. See docs/dask-image-contract.md in the broker repository for the full contract and a pinned base image to derive from.

# inside analysis.py
import os
from dask.distributed import Client

client = Client(scheduler_file=os.environ["SKA_DASK_SCHEDULER_FILE"])

The cluster is torn down when your command exits.

A rapthor pipeline

broker.run_rapthor(
    data_dir="/srv/storage/site/sa/my-observation",
    image="registry.example.org/tools/rapthor:latest",
    cpu=8,
    threads=8,
)

Watch and inspect

A Job caches nothing, so a job id is all you need later — including after a notebook restart:

job = broker.job("job-abc123")
job.state            # current state
job.status()         # concise view
job.logs()           # printable log tails
job.next_action()    # triage hint when a job looks stuck
job.cancel()

broker.jobs(limit=20)          # recent jobs
broker.is_ready()              # broker health

Defaults can live on the client instead of every call:

broker = Broker(
    "https://broker.example.org",
    token=my_access_token,
    image="registry.example.org/tools/app:1",
    input_url="dav://storm.example.org/sa/inputs",
)
Broker.from_env()   # BROKER_URL / BROKER_TOKEN / BROKER_IMAGE / ...

The transport layer

BrokerClient is one method per HTTP endpoint, each returning a requests.Response, for callers who want the responses themselves:

from ska_src_ef_broker_client import BrokerClient

client = BrokerClient("https://broker.example.org", bearer_token=token)
response = client.get_job("job-abc123")
print(response.json()["state"])

Broker is built on it — it fills in the submit payload, gives jobs an object identity, and turns polling into job.wait().

Notes

  • A token is required. Every call without one answers 401.
  • TLS: for a private CA pass its bundle — verify="/path/ca.crt". verify=False disables verification altogether, which exposes the bearer token these calls carry to anyone on the path; keep it out of anything but a throwaway probe.
  • A worked example of all three workload classes lives in the broker repository at demo/notebooks/broker_showcase.py (a marimo notebook).

Download files

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

Source Distribution

ska_src_ef_broker_client-0.1.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

ska_src_ef_broker_client-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file ska_src_ef_broker_client-0.1.0.tar.gz.

File metadata

  • Download URL: ska_src_ef_broker_client-0.1.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for ska_src_ef_broker_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 828ab86c3c3b240fb802cde5a0d7e982ee251b2f0b7e6838c1f3f9845ed79852
MD5 1ca47b9835bbd75001988f5213e5a12d
BLAKE2b-256 db5e3f15e603f300e68506250d789001a9575a7d3636c15938b3e40f48be5c47

See more details on using hashes here.

File details

Details for the file ska_src_ef_broker_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ska_src_ef_broker_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9db0f437e48da9c8ba067345fecb33b65e1c0811dc63d135ba1df68a0bd3ef36
MD5 38a2d479bd64cafee791cbccc2a0e540
BLAKE2b-256 a910618d4b1196d8c849dd58b1ac6e949935a8af19ac315a2a43ab4a9fcacc0d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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