coexist.schedulers.Scheduler#

class coexist.schedulers.Scheduler[source]#

Bases: ABC

An abstract class defining the interface that concrete schedulers need to implement.

A scheduler, in general, is a program that defines a way to split parallel workloads in some computing environment. More specifically, it allows calling a Python script with some command-line arguments in parallel; in the simplest case:

$> python3 some_script.py arg1 arg2 arg3

Here, python3 is the “scheduler”, simply creating a new OS process in which a Python interpreter executes some_script.py. This is implemented in the LocalScheduler class.

In a more complex, multi-cluster environment managed by SLURM:

$> sbatch job_submission.sh some_script.py arg1 arg2 arg3

Here, the sbatch job_submission.sh is the scheduling part, and the job_submission.sh SLURM script must be generated beforehand. This is implemented in the SlurmScheduler class.

Subclassing:

If you want to implement a concrete scheduler for another system, subclass Scheduler and implement the schedule(dirpath, index) method (dirpath is the directory where the computation is run, e.g. “access_seed123” and index is the job number), which will be called when launching each simulation to:

  • Generate any files needed to schedule a Python script’s execution.

  • Return a list of the system commands to be prepended to the Python scripts (e.g. [“python3”] and [“sbatch”, “job_submission.sh”] in the examples above).

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

schedule(dirpath, index)

abstract schedule(dirpath, index)[source]#