airsspy.scheduler#

Job scheduler interface for Slurm, SGE, and local execution.

Provides a unified interface for detecting the current scheduler environment, querying job metadata (CPUs, remaining walltime), and managing job arrays.

Module Contents#

Classes#

Scheduler

Base class for job scheduler interfaces.

Dummy

Dummy scheduler for local execution.

SGE

Scheduler object for Sun Grid Engine (SGE).

Slurm

Slurm scheduler interface.

Data#

API#

airsspy.scheduler.logger#

‘getLogger(…)’

class airsspy.scheduler.Scheduler[source]#

Base class for job scheduler interfaces.

Initialization

abstractmethod get_n_cpus() Optional[int][source]#

Return the number of CPUs allocated to this job.

property user_name: str#

Return the name of the current user.

abstractmethod get_remaining_seconds() int[source]#

Get the remaining walltime in seconds.

property is_in_job: bool#

Return whether we are inside a scheduler job.

abstract property job_id: Optional[str]#

Return the job ID.

classmethod get_scheduler() Optional[airsspy.scheduler.Scheduler][source]#

Detect and return a scheduler instance for the current environment.

Tries Slurm, SGE, then Dummy. Returns None if not in any job and Dummy is not appropriate.

class airsspy.scheduler.Dummy[source]#

Bases: airsspy.scheduler.Scheduler

Dummy scheduler for local execution.

Initialization

DEFAULT_REMAINING_TIME#

None

get_n_cpus() int[source]#
property job_id: str#
get_remaining_seconds() int[source]#

Get the remaining time. Defaults to 30 days.

property is_in_job: bool#
class airsspy.scheduler.SGE[source]#

Bases: airsspy.scheduler.Scheduler

Scheduler object for Sun Grid Engine (SGE).

Initialization

property job_id: Optional[str]#
property is_in_job: bool#
get_n_cpus() Optional[int][source]#

Get the number of CPUs from the NSLOTS environment variable.

get_max_run_seconds() Optional[int][source]#

Return the maximum run time in seconds.

get_end_time() Optional[datetime.datetime][source]#

Return the expected finish time of this job.

get_start_time() Optional[datetime.datetime][source]#

Return the start time of this job.

get_remaining_seconds() int[source]#

Return the remaining walltime in seconds.

class airsspy.scheduler.Slurm[source]#

Bases: airsspy.scheduler.Scheduler

Slurm scheduler interface.

Initialization

property is_in_job: bool#

Whether we are inside a Slurm job.

property job_id: Optional[str]#
get_end_time() Optional[datetime.datetime][source]#

Return the end time of this job.

get_remaining_seconds() int[source]#

Return the remaining walltime in seconds.

get_user_name() Optional[str][source]#

Parse the user name from task info.

get_n_cpus() Optional[str][source]#

Return number of CPUs allocated.

get_array_id() Optional[str][source]#

Return the array job ID, or None.

get_array_task_id() Optional[str][source]#

Return the array task ID, or None.

get_array_job_id() Optional[str][source]#

Return the array job ID as {array_id}_{task_id}.

hold_array(array_num: Optional[str] = None) None[source]#

Hold the array this job belongs to.

hold_all_pd_arrays(user_name: Optional[str] = None) None[source]#

Hold all pending arrays.

release_all_pd_arrays(user_name: Optional[str] = None) None[source]#

Release all pending arrays.

get_running_jobs(user_name: Optional[str] = None) Optional[list[str]][source]#

Return a list of running job IDs for the current user.

get_pd_arrays(user_name: Optional[str] = None) Optional[list[str]][source]#

Return a list of pending array job IDs.

__bool__() bool[source]#
__getitem__(key: str) Optional[str][source]#
__contains__(key: str) bool[source]#