Skip to main content

dss-cluster-sched

Runs ITK-SNAP Distributed Segmentation Service (DSS) tickets as jobs on a SLURM or LSF cluster. One scheduler process, on a login node, polls one or more DSS servers for tickets of the services it subscribes to, and submits one cluster job per ticket. Configurable limits cap how many jobs run and how many wait in the cluster queue.

How it works

  1. Each cycle, the scheduler asks every server which subscribed services have ready tickets (/api/pro/services/available).
  2. While the limits allow, it claims a ticket temporarily, for claim_timeout seconds, and submits a cluster job for it through psij-python.
  3. When the job starts, the job wrapper (python -m dss_cluster_sched.jobwrap) first claims the ticket for good (POST /api/pro/tickets/<id>/claim):
    • If the temporary claim lapsed while the job was queued, but nobody else took the ticket, the job still gets it.
    • If another provider took it, or another job is already working on it, the job exits without doing anything.
  4. The wrapper then runs your command. If the command fails, or the job is killed, while the ticket is still open, the wrapper attaches the last 200 lines of output to the ticket and marks it failed.

While a job waits in the cluster queue, its temporary claim may lapse and the ticket goes back to ready. If the same scheduler claims that ticket again, it does not submit a second job; the queued job keeps it. A queued job is cancelled only when its ticket is finished or deleted.

Temporary claims need itksnap-dss-server 0.3.0 or later on the DSS server, and itksnap-dss 0.3.0 or later (installed automatically).

Install

On a file system that the compute nodes can also see:

python3 -m venv /shared/venvs/dss
/shared/venvs/dss/bin/pip install dss-cluster-sched

Configure

Start from examples/config.yaml, which documents every key. It has five parts:

  • servers: DSS servers, each with its URL and the provider name registered there.
  • jobs: reusable job types. Each one has:
    • scheduler: queue, account, duration, cpus, gpus, memory, and custom psij attributes such as slurm.constraint or lsf.R;
    • environment: env, setup, modules and venv, applied in that order;
    • a command template and defaults for its variables.
  • services: what to subscribe to. Each one has a DSS service name (all its current versions) or a pinned githash, the job that runs it, and params. Two services can share a job and differ only in their params, e.g. two HyperASHS atlases.
  • limits: max_jobs (queued + running) and max_queued, set globally and in any server, job or service. A ticket is claimed only if every limit that applies allows one more job.
  • instance: identifies this scheduler. It is the provider "code" on DSS and part of each job name (dss.<instance>.<server>.<ticket>).

Command templates use {name} fields. Values come from the built-in variables first, then the job's defaults, then the service's params, with later values overriding earlier ones. The built-ins are server_url, server_key, ticket, service_key, service_name, service_githash, job_key, provider, provider_code, session_file, instance and user. Defaults and params can refer to other variables, e.g. workdir: /scratch/{user}/{ticket}. Every variable is also exported to the job as DSS_<NAME>.

dss-cluster-sched validate config.yaml

Log in

DSS login tokens work once: logging in replaces the token. The session it creates lasts, so log in once per server:

dss-cluster-sched login config.yaml        # paste a token from <server>/token

The session id is saved to <state_dir>/sessions/<server>.session with mode 600, and the jobs reuse it. For unattended setups, a server's token_file can hold a fresh token instead; it is used only when there is no valid session.

Run

dss-cluster-sched run config.yaml            # until SIGTERM/SIGINT
dss-cluster-sched run --once config.yaml     # a single cycle
dss-cluster-sched run --dry-run config.yaml  # show what would be claimed
dss-cluster-sched status config.yaml         # jobs being tracked

The scheduler records its jobs in <state_dir>/jobs.json. After a restart it re-attaches to them, so the limits still count them. Job specs and logs are kept under <state_dir>/jobs and <state_dir>/logs.

Writing a job

The job command runs on the compute node with these environment variables set: DSS_SERVER_URL, DSS_TICKET, DSS_SESSION_FILE and the other DSS_* variables. By the time it starts, the ticket is claimed for good. A Python job gets an authenticated client with:

from dss_cluster_sched.jobwrap import connect
client = connect()        # itksnap_dss.DSSClient using the scheduler's session
client.dssp_download_ticket(ticket, workdir)
...
client.dssp_set_status(ticket, 'success')

The job should set the ticket to success, or failed, itself. If it exits non-zero without doing so, the wrapper marks the ticket failed.

examples/neck_trim_job.py is a complete example to start from. It trims the neck from a T1 MRI with picsl_c3d, and shows how to:

  • connect, with or without dss_cluster_sched installed in the job's environment;
  • download the workspace and find a layer by tag;
  • report progress;
  • post log messages with attachments (command output and screenshots);
  • upload a result workspace;
  • report errors.

testing/dummy_job.py is a minimal one.

Testing

  • Unit and local tests: these run a real DSS server, and run jobs through psij's local executor.

    python -m venv .venv && .venv/bin/pip install -e '.[test]'
    .venv/bin/pytest tests
    
  • SLURM end to end in Docker: the container is a single-node SLURM 24.11 cluster with munge and no cgroups. It also runs a local DSS server with provider testprov and three dummy services, Dummy-AtlasA, Dummy-AtlasB and Dummy-Slow.

    docker compose run --rm cluster test     # docker/test_e2e.py
    docker compose up --build                # run the scheduler; web UI on http://localhost:8080
    docker compose exec -u dss cluster python /opt/src/docker/submit_tickets.py Dummy-AtlasA 5
    docker compose exec -u dss cluster dss-cluster-sched status /home/dss/e2e/config.yaml
    

LSF uses the same code path (executor: lsf), but has not been tested on a real LSF cluster.

Limitations

  • psij 0.9.11 ignores JobSpec.name in its batch templates. The job name is passed as a custom attribute instead: slurm.job-name for SLURM, lsf.J for LSF.
  • A queued job whose ticket was taken by another provider is not cancelled early; it exits as soon as it starts.
  • Bash jobs that call itksnap-wt must log in with itksnap-wt's own credentials; they cannot reuse the scheduler's session file.

Metadata

Release files for dss-cluster-sched 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dss-cluster-sched 0.1.0
File Size Uploaded Provenance Actions
dss_cluster_sched-0.1.0.tar.gz 34.0 kB With provenance Details for dss_cluster_sched-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dss-cluster-sched 0.1.0
File Interpreter ABI Platform Actions
dss_cluster_sched-0.1.0-py3-none-any.whl Python 3 none any Details for dss_cluster_sched-0.1.0-py3-none-any.whl

Total release size: 64.4 kB

Release files / dss_cluster_sched-0.1.0.tar.gz

Download URL dss_cluster_sched-0.1.0.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
96ebfdad04fdc299025abf4d05167d4c941de8e8b2b5a5dcd4c1d9e638d2d110
BLAKE2b-256 checksum
How to use checksums
9092f3ca9d3786e1f6674aeb8e4ebffe345ef4f477b6f792c88ad109ccaca0cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / dss_cluster_sched-0.1.0-py3-none-any.whl

Download URL dss_cluster_sched-0.1.0-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ad7bcc7b5f3775998f6c9c566b3432c337e3a772188903503f2747369c5d736
BLAKE2b-256 checksum
How to use checksums
2200e324dc0c051f9ca76b41192bbc80f82c0ad53bf6bdc93677f39da52c6137
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for dss-cluster-sched 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dss_cluster_sched-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page