schrodinger.tasks.queue module

class schrodinger.tasks.queue.QueueReport(*args, _param_type=<object object>, **kwargs)

Bases: CompoundParam

num_tasks: int

A parameter of the class.

num_done_tasks: int

A parameter of the class.

num_failed_tasks: int

A parameter of the class.

failure_infos: Dict[str, FailureInfo]

A parameter of the class.

failure_infosChanged

A pyqtSignal emitted by instances of the class.

failure_infosReplaced

A pyqtSignal emitted by instances of the class.

num_done_tasksChanged

A pyqtSignal emitted by instances of the class.

num_done_tasksReplaced

A pyqtSignal emitted by instances of the class.

num_failed_tasksChanged

A pyqtSignal emitted by instances of the class.

num_failed_tasksReplaced

A pyqtSignal emitted by instances of the class.

num_tasksChanged

A pyqtSignal emitted by instances of the class.

num_tasksReplaced

A pyqtSignal emitted by instances of the class.

class schrodinger.tasks.queue.QueueResults(*args, _param_type=<object object>, **kwargs)

Bases: CompoundParam

Data class to store the results of a queued task run and report them if requested.

We implement several dunder methods to make this class behave like a list of done tasks in order to maintain backwards compatibility with existing code.

done_tasks: List[AbstractTask]

A parameter of the class.

failed_tasks: List[AbstractTask]

A parameter of the class.

__len__() int
addTasks(tasks: List[AbstractTask]) None
makeReport() QueueReport
done_tasksChanged

A pyqtSignal emitted by instances of the class.

done_tasksReplaced

A pyqtSignal emitted by instances of the class.

failed_tasksChanged

A pyqtSignal emitted by instances of the class.

failed_tasksReplaced

A pyqtSignal emitted by instances of the class.

class schrodinger.tasks.queue.TaskQueue(*args, _param_type=<object object>, **kwargs)

Bases: SignalTask

A task that runs a queue of tasks. The TaskQueue is done when all its added tasks have completed, regardless of whether they completed successfully or failed. To use, add tasks with addTask and then start the task queue.

queuedTaskFinished

A pyqtSignal emitted by instances of the class.

queueDone

A pyqtSignal emitted by instances of the class.

max_running_tasks: int

A parameter of the class.

__init__(*args, **kwargs)
addTask(task)
getTasks()

Return all tasks in the queue.

Return type:

tuple[AbstractTask]

setUpMain()
start(*args, **kwargs)

This is the main method for starting a task. Start will check if a task is not already running, run preprocessing, and then run the task.

Failures in preprocessing will interrupt the task start, and the task will never enter the RUNNING state.

Parameters:

skip_preprocessing (bool) – whether to skip preprocessing. This can be useful if preprocessing was already performed prior to calling start.

calling_contextChanged

A pyqtSignal emitted by instances of the class.

calling_contextReplaced

A pyqtSignal emitted by instances of the class.

failure_infoChanged

A pyqtSignal emitted by instances of the class.

failure_infoReplaced

A pyqtSignal emitted by instances of the class.

inputChanged

A pyqtSignal emitted by instances of the class.

inputReplaced

A pyqtSignal emitted by instances of the class.

max_progressChanged

A pyqtSignal emitted by instances of the class.

max_progressReplaced

A pyqtSignal emitted by instances of the class.

max_running_tasksChanged

A pyqtSignal emitted by instances of the class.

max_running_tasksReplaced

A pyqtSignal emitted by instances of the class.

nameChanged

A pyqtSignal emitted by instances of the class.

nameReplaced

A pyqtSignal emitted by instances of the class.

outputChanged

A pyqtSignal emitted by instances of the class.

outputReplaced

A pyqtSignal emitted by instances of the class.

progressChanged

A pyqtSignal emitted by instances of the class.

progressReplaced

A pyqtSignal emitted by instances of the class.

progress_stringChanged

A pyqtSignal emitted by instances of the class.

progress_stringReplaced

A pyqtSignal emitted by instances of the class.

statusChanged

A pyqtSignal emitted by instances of the class.

statusReplaced

A pyqtSignal emitted by instances of the class.

class schrodinger.tasks.queue.AutoFileMode

Bases: IntEnum

FAILED_LOG = 1
FAILED_ALL = 2
NONE = 3
LOG = 4
ALL = 5
schrodinger.tasks.queue.run_tasks_in_parallel(task_list, autoname=True, basename=None, basedir=None)

This functions provides a convenient way of launching multiple tasks in parallel while taking care of boilerplate and prevents common mistakes.

By default, this function will:

  • Give each task a unique name

  • Give each task its own directory

  • Create a new JobDJ or TaskQueue

  • Run it with the provided tasks

  • Register the log files of any failed tasks with jobserver if using

    jobtasks

This can be used with either JobTasks or SubprocessTasks. SubprocessTasks will be run on a TaskQueue while JobTasks will be run on JobDJ.

Parameters:
  • task_list (list of tasks.AbstractTask) – the tasks to run

  • autoname (bool) – whether to automatically give each task a unique name

  • basename (str) – basename to be used in autonaming each task. Has no effect if autoname is set to False

  • basedir (str) – Base directory; all task taskdirs will be created inside. Defaults to cwd, and relative paths will be taken relative to cwd.

Returns:

the queue results, which can be used to generate a queue report.

Return type:

QueueResults

schrodinger.tasks.queue.run_tasks_on_queue(task_list, autoname=True, basename=None, basedir=None, max_running_tasks=None)

Launch multiple SubprocessTasks on a TaskQueue.

See run_tasks_in_parallel for more details. :param max_running_tasks: specifies how many tasks can be run simultaneously :type max_running_tasks: int

schrodinger.tasks.queue.run_tasks_on_dj(task_list, dj=None, autoname=True, basename=None, basedir=None, create_taskdirs=True, auto_file_mode=AutoFileMode.FAILED_LOG, fast_launch: bool = None, dj_init_kwargs: dict = None, dj_addJob_kwargs: dict = None, dj_run_kwargs: dict = None)

Launch multiple jobtasks on a jobdj. Use this function over run_tasks_in_parallel if you know you’ll be running jobtasks and you want to further customize how they’re run.

Parameters:
  • dj (JobDJ) – A JobDJ to run the tasks on. This is optional and useful if want a jobdj with specific settings.

  • autoname (bool) – whether to automatically give each task a unique name

  • basename (str) – basename to be used in autonaming each task. Has no effect if autoname is set to False

  • basedir (str) – Base directory; all task taskdirs will be created inside. Defaults to cwd, and relative paths will be taken relative to cwd.

  • create_taskdirs (bool) – whether to create the taskdirs. If False, the task will use base directory and relative directories will not be created.

  • auto_file_mode (AutoFileMode) – what subtask files to register with the parent job to be copied back by jobcontrol. Only has an effect if this function is called from inside a jobcontrol backend.

  • fast_launch (bool) – whether to use fast launch mode. When set to None, the fast launch behavior is determined by the environment variable SCHRODINGER_FAST_LAUNCH. Explicitly setting this parameter will override the environment variable.

  • dj_init_kwargs – A dictionary of keyword arguments to pass to JobDJ.__init__

  • dj_run_kwargs – A dictionary of keyword arguments to pass to JobDJ.run

  • dj_addJob_kwargs – A dictionary of keyword arguments to pass to JobDJ.addJob for each jobtask.

schrodinger.tasks.queue.process_completed_tasks(dj_jobs: list[JobControlJob], task_list: list[ComboJobTask], auto_file_mode=AutoFileMode.FAILED_LOG)

Update the tasks in tasks_list based on their corresponding jobs in the given jobs list. Also auto-registers files based on auto_file_mode.

NOTE: It is assumed that all of the tasks’ corresponding jobs are completed

and present in dj_jobs.

Parameters:
  • dj_jobs – The list of JobControlJob containing the completed jobs.

  • task_list – the list of tasks to update

  • auto_file_mode – what subtask files to register with the parent job to be copied back by jobcontrol. Only has an effect if this function is called from inside a jobcontrol backend.

schrodinger.tasks.queue.add_task_to_dj(dj: JobDJ, task: ComboJobTask, addJob_kwargs: dict[str, Any] | None = None, fast_launch: bool | None = None)

Add a single task to the JobDJ

NOTE: No verification is done to ensure the given task’s name is unique within existing tasks in the JobDJ. The caller is responsible for ensuring uniqueness.

NOTE: It is up to the caller to configure the task’s taskdir prior to calling this function.

Parameters:
  • dj – A JobDJ to run the task on.

  • task – The task to add to the JobDJ.

  • addJob_kwargs – A dictionary of keyword arguments to pass to JobDJ.addJob for the task.

  • fast_launch – whether to use fast launch mode. When set to None, the fast launch behavior is determined by the environment

schrodinger.tasks.queue.autoname_tasks(task_list, basename=None)

Sets unique names on all the tasks provided with an incrementing integer suffix. See run_tasks_on_dj for details.

schrodinger.tasks.queue.configure_taskdirs(task_list, autoname=True, basename=None, basedir=None, create_taskdirs=True)

Automatically configure task names and taskdirs to commonly used values.

Parameters:
  • task_list (list of tasks.AbstractTask) – the tasks to run

  • autoname (bool) – whether to automatically give each task a unique name

  • basename (str) – basename to be used in autonaming each task. Has no effect if autoname is set to False

  • basedir (str) – Base directory; all task taskdirs will be created inside. Defaults to cwd, and relative paths will be taken relative to cwd.

  • create_taskdirs (bool) – whether to create the taskdirs. If False, the task will use base directory and relative directories will not be created.

schrodinger.tasks.queue.auto_register_files(task_list, auto_file_mode=AutoFileMode.FAILED_LOG)

Automatically registers files from the subtask with the parent job (if applicable).