Skip to content

Conversation

Tobiaspk
Copy link

This PR adds support for scontrol and sacct interfaces, and updates the return logic of sbatch.

Changes

  • Added support for:
    • SlurmSacctWrapper: Parses resource info from sacct. Added as a variable to Slurm.
    • SlurmScontrolWrapper: Parses resource info from scontrol. Also added as a variable to Slurm.
  • Updated return logic for sbatch:
    • ⚠️ Possibly breaking change for some production code.
    • Now returns the job object (self) instead of just the job_id. This allows access to the job’s namespace and integrates smoothly with sacct and scontrol.
    • int(slurm) now returns the job_id, which integrates nicely with scancel.
  • Updated README.md with examples and docs.
  • ruff conform code

All tests are passing. The only exception is srun, which isn’t supported on our cluster. Would appreciate 2nd set of eyes on this.


Example usage

from simple_slurm import Slurm

slurm = Slurm()
job = slurm.sbatch("echo hello world")

# Refresh job info
slurm.sacct.update()
slurm.scontrol.update()

# Resource usage info (list of dicts)
print(slurm.sacct)

# Technical details (also list of dicts)
print(slurm.scontrol)

# Cancelling the job (still supported)
slurm.scancel.cancel_job(job)

@Tobiaspk
Copy link
Author

Tobiaspk commented Sep 5, 2025

@amq92 Ruff formatting works on my machine.

For the updated return behavior: instead of changing it immediately, could add an environment flag (SIMPLE_SLURM_RETURN_JOB=true/false) to control whether only the job_id or the job instance is returned, and a FutureWarning about the upcoming change to default if wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant