schrodinger.ui.qt.appframework2.jobs module

Job runners are subclasses of task runners. See the tasks module for more general information.

class schrodinger.ui.qt.appframework2.jobs.RunMode(value)

Bases: enum.Enum

An enumeration.

START = 1
WRITE = 2
STU = 3
class schrodinger.ui.qt.appframework2.jobs.JobOptions

Bases: object

A simple class for storing the options for a particular job runner. These options pertain to a runner, not to a specific job. For example, the host parameter only determines whether a host can be specified for this job type, not which host to use for any particular run.

__init__()
toDict()
class schrodinger.ui.qt.appframework2.jobs.JobConfig(job_options)

Bases: object

Holds the standard configuration settings for a particular job run. The job options determine what settings are available.

__init__(job_options)
Parameters

job_options (JobOptions) – the options for the associated job type.

applySettings(settings)
hostFlag()
dispFlag()
projFlag()
viewnameFlag()
appendFlags(cmdlist, run_mode=RunMode.START)

Takes a cmdlist and appends the standard configuration flags appropriate for the context. This will depend on whether the intent is to start or write the job and whether maestro is available.

Parameters
  • cmdlist (list) – the original command list

  • run_mode (RunMode) – which action is being taken - start, write, or STU

summaryText()

Generates the text to display in the status bar via the updateStatusText method.

class schrodinger.ui.qt.appframework2.jobs.JobWrapper(job, settings=None, name='', **kwargs)

Bases: schrodinger.ui.qt.appframework2.tasks.AbstractTaskWrapper

Wraps jobcontrol.Job objects to present a common interface for af2.tasks. See tasks.AbstractTaskWrapper for more information.

TASK_CLASS

alias of schrodinger.job.jobcontrol.Job

__init__(job, settings=None, name='', **kwargs)
Parameters
  • task (see derived class) – the underlying task object (depends on subclass)

  • name (str) – the task name

  • settings (dict) – the settings used to run this task

  • test_mode (bool) – disables type-checking of the task object. Used for mocking that task in tests

isRunning()

Whether this task is currently running.

status()

The current status of the task. The schema is flexible and can be agreed upon with the corresponding runner.

jobId()
getName()
setName(name)
settings()

Returns the settings that were used to run this task.

class schrodinger.ui.qt.appframework2.jobs.WrittenJobWrapper(task, settings=None, name='', test_mode=False)

Bases: schrodinger.ui.qt.appframework2.tasks.AbstractTaskWrapper

This is basically an empty wrapper for representing a written job.

TASK_CLASS

alias of str

isRunning()

Whether this task is currently running.

status()

The current status of the task. The schema is flexible and can be agreed upon with the corresponding runner.

jobId()
filename()
__init__(task, settings=None, name='', test_mode=False)
Parameters
  • task (see derived class) – the underlying task object (depends on subclass)

  • name (str) – the task name

  • settings (dict) – the settings used to run this task

  • test_mode (bool) – disables type-checking of the task object. Used for mocking that task in tests

getName()
setName(name)
settings()

Returns the settings that were used to run this task.

class schrodinger.ui.qt.appframework2.jobs.BaseJobRunner(messaging_callback=None, settings_callback=None)

Bases: schrodinger.ui.qt.appframework2.tasks.AbstractTaskRunner

A job runner is a type of task runner that performs its task via launching a job under job control.

__init__(messaging_callback=None, settings_callback=None)

Initializes a new task runner

Parameters

messaging_callback

callback used for interacting with the user. This includes both reporting results or errors and asking questions to the user. The callback should be of the form:

f(message_type, text, options=None, runner=None)

where message_type is one of ERROR, WARNING, or QUESTION, text is the text of the message to be displayed, and options is an optional dict which can be used by the callback. For example, a dialog title could be passed to the callback via the options dict. The callback should never depend on the presence or absence of any options. The runner is simply the runner that is making the call, so that the callback can tell which runner is invoking the callback.

When the message is a question, the function should return the user’s response, typically True or False for a yes/no question.

Parameters

settings_callback

callback for communicating state with the parent object. This callback can be used both to push state to or pull state from the parent object. The callback should be of the form:

f(settings=None, runner=None)

If no settings are passed in, the callback should return the state of the parent object (i.e. the panel state) in the form of a dictionary.

The runner can be passed in as well if the callback needs to access the runner to properly process the callback.

If a settings dictionary is passed in, the callback should apply any settings in the dictionary to the parent object (thus altering its state). Passing in an empty dictionary is a no-op.

start()

Starts the task. This includes the preliminary work of calling preValidate() and running validation before attempting to actually start the task itself.

The actual starting of the task should be handled in the _start method in the derived classes and will vary depening on the type of runner.

postProcess(task)

Download job outputs after the job completes.

resetState()
validateJobName(**kwargs)
addTask(task)

Add a new task to be tracked. This should be called whenever a task is started.

Parameters

task (AbstractTaskWrapper) – the task

findJob(jobid)

Finds a wrapped job by its job id.

Parameters

jobid (str) – the job id

Returns

the job

Return type

JobWrapper

viewname()
update()

Slot method to update the state of the job runner.

write()

Call this to write out a job to be run later.

getSHFilename()

Returns the .sh filename for the next job.

writeSTU()

Writes out a STU test set.

createJobDir()
nextJobDir()
makeSchrodingerCmd(*args)

Builds a $SCHRODINGER command string from all the args passed in. The resulting string is suitable for use in a cmdlist and formatted for use in starting or writing the job depending on self.run_mode. In START mode, the $SCHRODINGER environment variable will be expanded. In WRITE mode, it will stay as $SCHRODINGER and the path will be delimited with linux-style forward slashes.

Example: self.makeSchrodingerCmd(‘utilities’, ‘my_utility’) will return “${SCHRODINGER}/utilities/my_utility” in WRITE mode.

getSchrodingerRun()

Returns the correct version of the $SCHRODINGER/run string. This will depend on whether the intent is to start or to write the job.

makeCmdList()

Implement this to generate a cmdlist. This cmdlist will be used for write functionality.

setupJobOptions(options)

Override this to set the job options for this job. The options is passed in by the framework. Modify and return the options object. The options object will determine, for example, what the config dialog should look like. For example:

options.incorporation = False
options.create_job_dir = False
return options

If this method is not overridden, default options will be used.

Parameters

options (JobOptions) – the options object to be customized.

jobOptions()
setConfig(config)
getNextConfig()
appendConfigFlags(cmdlist)
setCustomName(name)

Sets a custom name for the next task to be run.

Parameters

name (str) – the custom name. Pass in an empty string to return to standard naming.

updateStatusText()

Override this to update the status, for example, when settings have changed or the current task runner is switched.

blockSignals(self, b: bool) bool
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent)
defaultSettings()

Override this method to define default values for any settings. This dictionary of default settings will be used to reset the parent.

deleteLater(self)
destroyed

destroyed(self, object: typing.Optional[QObject] = None) [signal]

disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
error(text, caption='Error')
event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findTask(name)
info(text, caption='Info')
inherits(self, classname: str) bool
installEventFilter(self, a0: QObject)
isRunning()
isSignalConnected(self, signal: QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, id: int)
metaObject(self) QMetaObject
moveToThread(self, thread: QThread)
nameChanged
names()
nextName(name_list=None)

Returns the name that will be assigned to the next task that gets run. There is no currentName(), as multiple tasks might be running concurrently. To get the name of an existing task, use task.getName().

If a custom name has been set, that will be used as the next name. Otherwise, the base name will be used to generate a new unique name.

This method can be overridden to alter the task naming behavior.

Parameters

name_list (list of basestring) – Optional list of names to uniquify against. If not given, the name will be compared against the stored self.names()

objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

parent(self) QObject
postStart(task)

Override this to include any logic that should be run immediately after a task is started. This will only be run after a task actually starts.

The started task is passed in as a parameter to allow interaction with the task instance. Note that there is no guarantee that the task is still running when this method is called.

Parameters

task (AbstractTaskWrapper) – the task that was just started

preValidate()

Override this to include any logic that should be run prior to the validation step.

Returns

Whether this step has succeeded. Returning False will result in aborting the task

Return type

bool

property(self, name: str) Any
pullSettings()

This method calls the settings callback, which should return the user’s input for this job, such as input files, options, etc. For GUI panels, this is how the panel state is applied to the job runner.

pushSettings(settings=None)

Pushes a settings dictionary via the settings callback. Doing this will alter the state of the parent object (generally the panel). This function can be used to reset the panel or load saved presets.

If a settings dictionary is not passed in, the current job settings will be used.

Parameters

settings (dict) – a settings dictionary to push to the parent object

pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

question(text, caption='Question')
receivers(self, signal: PYQT_SIGNAL) int
removeEventFilter(self, a0: QObject)
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

Parameters

results (ValidationResults) – Set of results generated by validate()

reset()

Resets the parent object using the default settings defined by the task runner.

resetAll()
resetAllRequested
runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

sender(self) QObject
senderSignalIndex(self) int
setCallbacks(messaging_callback=None, settings_callback=None)
setObjectName(self, name: str)
setParent(self, a0: QObject)
setProperty(self, name: str, value: Any) bool
setRunnerOptions()

Optional override to set options for the runner. Not overriding this at all results in using all default values.

self.allow custom_name - whether name is user-editable. Default: False

self.allow_concurrent - whether another task can be started while one is still running. Default: True

self.history_length - how many past jobs to keep track of. Default: 5

self.base_name - the base for task names. The base name gets modified to generate unique task names. Ex. MyTask_3. Default: “task”

self.runner_name - a name to describe the type of task. Equivalent to program_name for jobs. Default: ‘task’

settings()
showMessage(message_type, text, options=None)

Communicates with the parent object via the messaging_callback. This method generally doesn’t need to be called; call error, warning, question, or info instead.

Parameters
  • message_type (int) – the type of message to send

  • text (str) – the main text of the message

  • options (dict) – a dictionary of other options to be processed by the messaging_callback.

signalsBlocked(self) bool
startFailed
startRequested
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
stateChanged
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
status(text, timeout=3000, color=None)

Request a status message to be displayed by the runner’s parent.

Parameters
  • text (str) – the text to display

  • timeout (int) – duration in ms to display the status. A timeout of 0 results in a permanent message.

  • color (QtGui.QColor) – color of the status message.

taskEnded
taskStarted
tasks()
thread(self) QThread
timerEvent(self, a0: QTimerEvent)
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str
warning(text, caption='Warning')
class schrodinger.ui.qt.appframework2.jobs.CmdJobRunner(messaging_callback=None, settings_callback=None)

Bases: schrodinger.ui.qt.appframework2.jobs.BaseJobRunner

This is the basic job runner for setting up and running a cmd line job. The job is launched using jobcontrol.launch_job().

makeCmdList()

This is the main method that needs to be implemented to define a specific cmd job runner. It should just return a complete cmd list for the job to be launched. Standard job options should be left off.

__init__(messaging_callback=None, settings_callback=None)

Initializes a new task runner

Parameters

messaging_callback

callback used for interacting with the user. This includes both reporting results or errors and asking questions to the user. The callback should be of the form:

f(message_type, text, options=None, runner=None)

where message_type is one of ERROR, WARNING, or QUESTION, text is the text of the message to be displayed, and options is an optional dict which can be used by the callback. For example, a dialog title could be passed to the callback via the options dict. The callback should never depend on the presence or absence of any options. The runner is simply the runner that is making the call, so that the callback can tell which runner is invoking the callback.

When the message is a question, the function should return the user’s response, typically True or False for a yes/no question.

Parameters

settings_callback

callback for communicating state with the parent object. This callback can be used both to push state to or pull state from the parent object. The callback should be of the form:

f(settings=None, runner=None)

If no settings are passed in, the callback should return the state of the parent object (i.e. the panel state) in the form of a dictionary.

The runner can be passed in as well if the callback needs to access the runner to properly process the callback.

If a settings dictionary is passed in, the callback should apply any settings in the dictionary to the parent object (thus altering its state). Passing in an empty dictionary is a no-op.

addTask(task)

Add a new task to be tracked. This should be called whenever a task is started.

Parameters

task (AbstractTaskWrapper) – the task

appendConfigFlags(cmdlist)
blockSignals(self, b: bool) bool
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
connectNotify(self, signal: QMetaMethod)
createJobDir()
customEvent(self, a0: QEvent)
defaultSettings()

Override this method to define default values for any settings. This dictionary of default settings will be used to reset the parent.

deleteLater(self)
destroyed

destroyed(self, object: typing.Optional[QObject] = None) [signal]

disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
error(text, caption='Error')
event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findJob(jobid)

Finds a wrapped job by its job id.

Parameters

jobid (str) – the job id

Returns

the job

Return type

JobWrapper

findTask(name)
getNextConfig()
getSHFilename()

Returns the .sh filename for the next job.

getSchrodingerRun()

Returns the correct version of the $SCHRODINGER/run string. This will depend on whether the intent is to start or to write the job.

info(text, caption='Info')
inherits(self, classname: str) bool
installEventFilter(self, a0: QObject)
isRunning()
isSignalConnected(self, signal: QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
jobOptions()
killTimer(self, id: int)
makeSchrodingerCmd(*args)

Builds a $SCHRODINGER command string from all the args passed in. The resulting string is suitable for use in a cmdlist and formatted for use in starting or writing the job depending on self.run_mode. In START mode, the $SCHRODINGER environment variable will be expanded. In WRITE mode, it will stay as $SCHRODINGER and the path will be delimited with linux-style forward slashes.

Example: self.makeSchrodingerCmd(‘utilities’, ‘my_utility’) will return “${SCHRODINGER}/utilities/my_utility” in WRITE mode.

metaObject(self) QMetaObject
moveToThread(self, thread: QThread)
nameChanged
names()
nextJobDir()
nextName(name_list=None)

Returns the name that will be assigned to the next task that gets run. There is no currentName(), as multiple tasks might be running concurrently. To get the name of an existing task, use task.getName().

If a custom name has been set, that will be used as the next name. Otherwise, the base name will be used to generate a new unique name.

This method can be overridden to alter the task naming behavior.

Parameters

name_list (list of basestring) – Optional list of names to uniquify against. If not given, the name will be compared against the stored self.names()

objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

parent(self) QObject
postProcess(task)

Download job outputs after the job completes.

postStart(task)

Override this to include any logic that should be run immediately after a task is started. This will only be run after a task actually starts.

The started task is passed in as a parameter to allow interaction with the task instance. Note that there is no guarantee that the task is still running when this method is called.

Parameters

task (AbstractTaskWrapper) – the task that was just started

preValidate()

Override this to include any logic that should be run prior to the validation step.

Returns

Whether this step has succeeded. Returning False will result in aborting the task

Return type

bool

property(self, name: str) Any
pullSettings()

This method calls the settings callback, which should return the user’s input for this job, such as input files, options, etc. For GUI panels, this is how the panel state is applied to the job runner.

pushSettings(settings=None)

Pushes a settings dictionary via the settings callback. Doing this will alter the state of the parent object (generally the panel). This function can be used to reset the panel or load saved presets.

If a settings dictionary is not passed in, the current job settings will be used.

Parameters

settings (dict) – a settings dictionary to push to the parent object

pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

question(text, caption='Question')
receivers(self, signal: PYQT_SIGNAL) int
removeEventFilter(self, a0: QObject)
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

Parameters

results (ValidationResults) – Set of results generated by validate()

reset()

Resets the parent object using the default settings defined by the task runner.

resetAll()
resetAllRequested
resetState()
runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

sender(self) QObject
senderSignalIndex(self) int
setCallbacks(messaging_callback=None, settings_callback=None)
setConfig(config)
setCustomName(name)

Sets a custom name for the next task to be run.

Parameters

name (str) – the custom name. Pass in an empty string to return to standard naming.

setObjectName(self, name: str)
setParent(self, a0: QObject)
setProperty(self, name: str, value: Any) bool
setRunnerOptions()

Optional override to set options for the runner. Not overriding this at all results in using all default values.

self.allow custom_name - whether name is user-editable. Default: False

self.allow_concurrent - whether another task can be started while one is still running. Default: True

self.history_length - how many past jobs to keep track of. Default: 5

self.base_name - the base for task names. The base name gets modified to generate unique task names. Ex. MyTask_3. Default: “task”

self.runner_name - a name to describe the type of task. Equivalent to program_name for jobs. Default: ‘task’

settings()
setupJobOptions(options)

Override this to set the job options for this job. The options is passed in by the framework. Modify and return the options object. The options object will determine, for example, what the config dialog should look like. For example:

options.incorporation = False
options.create_job_dir = False
return options

If this method is not overridden, default options will be used.

Parameters

options (JobOptions) – the options object to be customized.

showMessage(message_type, text, options=None)

Communicates with the parent object via the messaging_callback. This method generally doesn’t need to be called; call error, warning, question, or info instead.

Parameters
  • message_type (int) – the type of message to send

  • text (str) – the main text of the message

  • options (dict) – a dictionary of other options to be processed by the messaging_callback.

signalsBlocked(self) bool
start()

Starts the task. This includes the preliminary work of calling preValidate() and running validation before attempting to actually start the task itself.

The actual starting of the task should be handled in the _start method in the derived classes and will vary depening on the type of runner.

startFailed
startRequested
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
stateChanged
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
status(text, timeout=3000, color=None)

Request a status message to be displayed by the runner’s parent.

Parameters
  • text (str) – the text to display

  • timeout (int) – duration in ms to display the status. A timeout of 0 results in a permanent message.

  • color (QtGui.QColor) – color of the status message.

taskEnded
taskStarted
tasks()
thread(self) QThread
timerEvent(self, a0: QTimerEvent)
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str
update()

Slot method to update the state of the job runner.

updateStatusText()

Override this to update the status, for example, when settings have changed or the current task runner is switched.

validateJobName(**kwargs)
viewname()
warning(text, caption='Warning')
write()

Call this to write out a job to be run later.

writeSTU()

Writes out a STU test set.

schrodinger.ui.qt.appframework2.jobs.cmdlist_to_cmd(cmdlist)

Converts a command list to a command string. Don’t do this if you can possibly avoid it.

Parameters

cmdlist (list) – a list of commands

Returns

str

schrodinger.ui.qt.appframework2.jobs.set_sh_file_flags(filename)
schrodinger.ui.qt.appframework2.jobs.get_first_hostname(host)

Given a host string, get the corresponding hosts list from jobcontrol and return the first hostname from that list.

Parameters

host (string) –

Hosts string which determine the string value of result server argument. These are values usually from configuration dialog and is of the form “galina” or “galina:1” or “galina,monica” or “galina:2,monica:3” or “galina monica” or “galina:2 monica:3”.

rtype

str

return

Hostname based on the first of the first hosts in the jobcontrol list.

schrodinger.ui.qt.appframework2.jobs.job_belongs_to_panel(jobid, viewname)

Return True if jobid belongs to viewname of a panel. Used by incorporation callbacks to determine if the job belongs to us.

Parameters
  • jobid (str) – jobid for a given job

  • viewname (str) – viewname corresponding to panel