Attention

This project is still in an early phase of development.

The python API is not yet stable, and some aspects of the schema for the blueprint and workplan will likely evolve. Therefore whilst you are welcome to try out using the package, we cannot yet guarantee backwards compatibility. We expect to reach a more stable version in 2026.

SlurmJob#

class cstar.execution.scheduler_job.SlurmJob(scheduler: Scheduler, commands: str, account_key: str, cpus: int, nodes: int | None = None, cpus_per_node: int | None = None, script_path: str | Path | None = None, run_path: str | Path | None = None, job_name: str | None = None, output_file: str | Path | None = None, queue_name: str | None = None, send_email: bool | None = True, walltime: str | None = None, depends_on: Iterable[str] = ())#

Bases: SchedulerJob

Represents a job submitted to the SLURM scheduler.

This class extends SchedulerJob to handle SLURM-specific functionality for job submission, status retrieval, and script generation.

scheduler#

The SLURM scheduler managing this job.

Type:

SlurmScheduler

commands#

The commands to execute within the job script.

Type:

str

account_key#

The account key associated with the job for resource tracking.

Type:

str

cpus#

The total number of CPUs required for the job.

Type:

int

nodes#

The number of nodes to request. If not provided and a specific nodes x CPUs distribution is required, C-Star will attempt to calculate an appropriate number of nodes.

Type:

int or None

cpus_per_node#

The number of CPUs per node to request. If not provided and a specific nodes x CPUs distribution is required, C-Star will attempt to calculate an appropriate number of CPUs per node.

Type:

int or None

script_path#

The file path where the job script will be saved.

Type:

Path

run_path#

The directory where the job will be executed.

Type:

Path

job_name#

The name of the job.

Type:

str

output_file#

The file path for job output.

Type:

Path

queue_name#

The name of the SLURM queue (partition or QOS) to which the job will be submitted.

Type:

str

walltime#

The maximum walltime for the job, in the format “HH:MM:SS”.

Type:

str

id#

The unique job ID assigned by the SLURM scheduler. None if the job has not been submitted.

Type:

int or None

status#

The current status of the job, retrieved from SLURM.

Type:

ExecutionStatus

script#

The SLURM-specific job script, including directives and commands.

Type:

str

submit()#

Submit the job to the SLURM scheduler.

cancel()#

Cancel the job using the SLURM scancel command.

Methods

SlurmJob.cancel()

Cancel the job in the SLURM scheduler.

SlurmJob.get_batch()

SlurmJob.save_script()

Save the job script to a file.

SlurmJob.submit()

Submit the job to the SLURM scheduler.

SlurmJob.updates([seconds])

Stream live updates from the task's output file.

Attributes

SlurmJob.account_key

The account key associated with the job for resource tracking.

SlurmJob.commands

The commands to execute within the job script.

SlurmJob.cpus

The total number of CPUs required for the job.

SlurmJob.cpus_per_node

The number of CPUs per node to request.

SlurmJob.id

Retrieve the unique job ID assigned by the scheduler.

SlurmJob.job_name

The name of the job.

SlurmJob.log

Return the logger instance for this class.

SlurmJob.nodes

The number of nodes to request.

SlurmJob.output_file

The file in which to write this job's STDOUT and STDERR.

SlurmJob.queue

The queue to which the job will be submitted.

SlurmJob.queue_name

The name of the queue to which the job will be submitted.

SlurmJob.scheduler

The scheduler managing this job (e.g., a SlurmScheduler or PBSScheduler instance)

SlurmJob.script

Generate the SLURM-specific job script to be submitted to the scheduler.

SlurmJob.status

Retrieve the current status of the job from the SLURM scheduler.

SlurmJob.walltime

SS`.