A Prefect 3 TaskRunner that submits tasks to SLURM clusters via submitit
Project description
prefect-submitit
A Prefect 3 TaskRunner that submits tasks to SLURM clusters via submitit.
Features
- Single task submission -- submit individual Prefect tasks as SLURM jobs
- Job arrays -- submit
task.map()calls as SLURM job arrays with automatic chunking when the array exceeds cluster limits - Batched execution -- group multiple items per SLURM job with
units_per_workerto reduce scheduling overhead - Local mode -- swap to local execution for testing without changing your flow
code (
execution_mode="local"orSLURM_TASKRUNNER_BACKEND=local) - Prefect UI integration -- task run names include SLURM job IDs for easy
cross-referencing with
squeue/sacct
Installation
pip install prefect-submitit
Or with conda (after the first conda-forge release):
conda install -c conda-forge prefect-submitit
Quick Start
from prefect import flow, task
from prefect_submitit import SlurmTaskRunner
@task
def add(x: int, y: int) -> int:
return x + y
@flow(task_runner=SlurmTaskRunner(partition="cpu", time_limit="00:10:00"))
def my_flow():
# Single task
future = add.submit(1, 2)
print(future.result()) # 3
# Map over inputs (submitted as a SLURM job array)
futures = add.map([1, 2, 3], [4, 5, 6])
print([f.result() for f in futures]) # [5, 7, 9]
if __name__ == "__main__":
my_flow()
Configuration
SlurmTaskRunner(
partition="gpu", # SLURM partition
time_limit="04:00:00", # Wall time (HH:MM:SS)
mem_gb=16, # Memory per job
gpus_per_node=1, # GPUs per job
units_per_worker=10, # Items per SLURM job (batched mode)
execution_mode="slurm", # "slurm" or "local"
slurm_array_parallelism=100, # Max concurrent array tasks
log_folder="slurm_logs", # Where submitit writes logs
fail_on_error=True, # Raise on SLURM job failure
)
Any additional keyword arguments are passed through to submitit (e.g.
slurm_gres="gpu:a100:1").
Local Testing
Set the environment variable to skip SLURM entirely:
export SLURM_TASKRUNNER_BACKEND=local
Or pass it directly:
SlurmTaskRunner(execution_mode="local")
Development
Requires Pixi:
pixi install
pixi run -e dev test
pixi run -e dev fmt
License
BSD 3-Clause. See LICENSE for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefect_submitit-0.1.3.tar.gz.
File metadata
- Download URL: prefect_submitit-0.1.3.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
598c4eefbc481cc64267e33ed9c2f31fda2f166e4be9d0ebb6702cb30d102ace
|
|
| MD5 |
efe15f164eedbf2be4058a1394c88b14
|
|
| BLAKE2b-256 |
a01e1dbb46906420e5f6c3fba62f8aab288dbee604d19a36b21bce50383e0f15
|
Provenance
The following attestation bundles were made for prefect_submitit-0.1.3.tar.gz:
Publisher:
release.yml on dexterity-systems/prefect-submitit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_submitit-0.1.3.tar.gz -
Subject digest:
598c4eefbc481cc64267e33ed9c2f31fda2f166e4be9d0ebb6702cb30d102ace - Sigstore transparency entry: 990388478
- Sigstore integration time:
-
Permalink:
dexterity-systems/prefect-submitit@1cf31d6a182a9092ffb653bbbb0957ef47b76596 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dexterity-systems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1cf31d6a182a9092ffb653bbbb0957ef47b76596 -
Trigger Event:
release
-
Statement type:
File details
Details for the file prefect_submitit-0.1.3-py3-none-any.whl.
File metadata
- Download URL: prefect_submitit-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0bc3e22d8163f7d2c780d092aca08bc107c93d713df7ee22d366d394f7fbe56
|
|
| MD5 |
d60c8cceaa2bc57201145bd6647f876f
|
|
| BLAKE2b-256 |
c5c1cab74bbb0b1f8f58513c30d4bd14571a7e8bfb858f9dd4f98a47b3873428
|
Provenance
The following attestation bundles were made for prefect_submitit-0.1.3-py3-none-any.whl:
Publisher:
release.yml on dexterity-systems/prefect-submitit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_submitit-0.1.3-py3-none-any.whl -
Subject digest:
c0bc3e22d8163f7d2c780d092aca08bc107c93d713df7ee22d366d394f7fbe56 - Sigstore transparency entry: 990388481
- Sigstore integration time:
-
Permalink:
dexterity-systems/prefect-submitit@1cf31d6a182a9092ffb653bbbb0957ef47b76596 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dexterity-systems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1cf31d6a182a9092ffb653bbbb0957ef47b76596 -
Trigger Event:
release
-
Statement type: