schrodinger.tasks.queue module¶
- class schrodinger.tasks.queue.QueueReport(*args, _param_type=<object object>, **kwargs)¶
Bases:
schrodinger.models.parameters.CompoundParam
- num_subtasks: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- num_done_tasks: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- num_failed_tasks: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- failure_infos: Dict[str, schrodinger.tasks.tasks.FailureInfo]¶
A Param to represent dictionaries. Values of this param will have a
mutated
signal that will be emitted whenever any mutation method is called.The constructor optionally takes a
value_class
keyword argument to specify what type of class the values will be. This information will be used for jsonifying the dictionary if specified. (Note that non-string keys are not currently supported for jsonification. This may change in the future. See PANEL-13029).
- DataClass¶
This class can be used to declare a public attribute on a
CompoundParam
. Declared public attributes can be used without error.Example usage:
class Coord(CompoundParam): x: int y: int note = NonParamAttribute() coord = Coord() coord.note = "hello" # No error
- __init__(default_value=<object object>, _param_type=<object object>, **kwargs)¶
- classmethod addSubParam(name, param, update_owner=True)¶
- blockSignals(self, b: bool) bool ¶
- block_signal_propagation()¶
- childEvent(self, a0: QChildEvent)¶
- children(self) List[QObject] ¶
- classmethod configureParam()¶
Override this class method to set up the abstract param class (e.g. setParamReference on child params.)
- connectNotify(self, signal: QMetaMethod)¶
- customEvent(self, a0: QEvent)¶
- classmethod defaultValue()¶
Returns the default value for this abstract param:
default_atom = Atom.defaultValue() assert Atom.coord.x == 0
- 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] ¶
- event(self, a0: QEvent) bool ¶
- eventFilter(self, a0: QObject, a1: QEvent) bool ¶
- failure_infosChanged¶
- failure_infosReplaced¶
- 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]
- classmethod fromJson(json_obj)¶
A factory method which constructs a new object from a given dict loaded from a json string or file.
- Parameters
json_obj (dict) – A json-loaded dictionary to create an object from.
- Returns
An instance of this class.
- Return type
cls
- classmethod fromJsonImplementation(json_dict)¶
Sets the value of this compound param value object from a JSON dict.
Warning
This should never be called directly.
- getAbstractParam()¶
Return the corresponding abstract param for this instance.
- classmethod getJsonBlacklist()¶
Override to customize what params are serialized.
Implementations should return a list of abstract params that should be omitted from serialization.
- ..NOTE
Returned abstract params must be direct child params of
cls
, e.g.cls.name
, notcls.coord.x
.
- classmethod getParamSignal(obj, signal_type='Changed')¶
- classmethod getParamValue(obj)¶
Enables access to a param value on a compound param via an abstract param reference:
a = Atom() assert Atom.coord.x.getParamValue(a) == 0 # ints default to 0 a.coord.x = 3 assert Atom.coord.x.getParamValue(a) == 3
- Parameters
param (CompoundParam) – The owner param to get a param value from
- classmethod getSubParam(name)¶
Get the value of a subparam using the string name:
c = Coord() assert c.getSubParam('x') == 0
Note
Using the string name to access params is generally discouraged, but can be useful for serializing/deserializing param data.
- Parameters
name (str) – The name of the subparam to get the value for.
- classmethod getSubParams()¶
Return a dictionary mapping subparam names to their values.
- getTypeHint()¶
- get_version()¶
Method to get the version of a particular object. Defaults to the current version of mmshare. This class can be overridden for custom versioning behavior.
- inherits(self, classname: str) bool ¶
- initAbstract()¶
- initConcrete()¶
Override to customize initialization of concrete params.
- initializeValue()¶
Override to dynamically set up the default value of the param. Useful for default values that are determined at runtime. This is called any time the param is reset.
- installEventFilter(self, a0: QObject)¶
- classmethod isAbstract()¶
Whether the param is an “abstract” param.
- isDefault()¶
Whether the current value of this instance matches the default value.
- isSignalConnected(self, signal: QMetaMethod) bool ¶
- isWidgetType(self) bool ¶
- isWindowType(self) bool ¶
- killTimer(self, id: int)¶
- metaObject(self) QMetaObject ¶
- moveToThread(self, thread: QThread)¶
- num_done_tasksChanged¶
- num_done_tasksReplaced¶
- num_failed_tasksChanged¶
- num_failed_tasksReplaced¶
- num_subtasksChanged¶
- num_subtasksReplaced¶
- objectName(self) str ¶
- objectNameChanged¶
objectNameChanged(self, objectName: str) [signal]
- classmethod owner()¶
Get the owner of the param:
# Can be called on an abstract param: assert Coord.x.owner() == Coord # ...or on an instance of a CompoundParam a = Atom() assert a.coord.owner() == a
- classmethod ownerChain()¶
Returns a list of param owners starting from the toplevel param and ending with self. Examples:
foo.bar.atom.coord.ownerChain()
will return[foo, bar, atom, coord]
where every item is a concrete param.Foo.bar.atom.coord.x.ownerChain()
will return[Foo, Foo.bar, Foo.atom.coord, Foo.atom.coord.x]
where every item is an abstract params.
- classmethod paramName()¶
Get the name of the param:
# Can be called on an abstract param: print(Coord.x.paramName()) # 'x' # ...or on an instance of a CompoundParam a = Atom() a.coord.paramName() # 'coord'
- parent(self) QObject ¶
- property(self, name: str) Any ¶
- 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.
- receivers(self, signal: PYQT_SIGNAL) int ¶
- removeEventFilter(self, a0: QObject)¶
- reset(*abstract_params)¶
Resets this compound param to its default value:
class Line(CompoundParam): start = Coord(x=1, y=2) end = Coord(x=4, y=5) line = Line() line.start.x = line.end.x = 10 assert line.start.x == line.end.x == 10 line.reset() assert line.start.x == 1 assert line.end.x == 4
Any number of abstract params may be passed in to perform a partial reset of only the specified params:
line.start.x = line.end.x = 10 line.reset(Line.start.x) # resets just start.x assert line.start.x == 1 assert line.end.x == 10 line.reset(Line.end) # resets the entire end point assert line.end.x == 4 line.start.y = line.end.y = 10 line.reset(Line.start.y, Line.end.y) # resets the y-coord of both assert line.start.y == 2 assert line.end.y == 5
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setObjectName(self, name: str)¶
- classmethod setParamValue(obj, value)¶
Set the value of a param on an object by specifying the instance and the value:
# Setting the param value of a basic param a = Atom() Atom.coord.x.setParamValue(a, 5) assert a.coord.x == 5 # setParamValue can also be used to set the value of CompoundParams c = Coord() c.x = 10 atom.coord.setParamValue(a, c) assert atom.coord.x == 10
- Parameters
param – The owner param to set a subparam value of.
value – The value to set the subparam value to.
- setParent(self, a0: QObject)¶
- setProperty(self, name: str, value: Any) bool ¶
- classmethod setReference(param1, param2)¶
Call this class method from configureParam to indicate that two params should be kept in sync. The initial values will start with the default value of
param1
. Example:class Square(CompoundParam): width: float = 5 height: float = 10 @classmethod def configureParam(cls): super().configureParam() cls.setReference(cls.width, cls.height) square = Square() assert square.width == square.height == 5 # Default value of width # takes priority square.height = 7 assert square.width == square.height == 7 square.width = 6 assert square.width == square.height == 6
- Parameters
param1 – The first abstract param to keep synced
param2 – The second abstract param. After instantiation, this param will take on the value of param1.
- setValue(value=None, **kwargs)¶
Set the value of this
CompoundParam
to matchvalue
.- Parameters
value – The value to set this
CompoundParam
to. It should be the same type as thisCompoundParam
.kwargs – For internal use only.
- signalsBlocked(self) bool ¶
- skip_eq_check()¶
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int ¶
- staticMetaObject = <PyQt6.QtCore.QMetaObject object>¶
- thread(self) QThread ¶
- timerEvent(self, a0: QTimerEvent)¶
- toDict()¶
Return a dictionary version of this
CompoundParam
. The returned dictionary is fully nested and contains noCompoundParam
instancesa = Atom() a_dict = a.toDict() assert a_dict['coord']['x'] == 0 assert a_dict['coord'] == {'x':0, 'y':0}
- toJson(_mark_version=True)¶
Create and returns a data structure made up of jsonable items.
- Return type
An instance of one the classes from NATIVE_JSON_DATATYPES
- toJsonImplementation()¶
Returns a JSON representation of this value object.
Warning
This should never be called directly.
- tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str ¶
- valueChanged¶
- class schrodinger.tasks.queue.QueueResults(*args, _param_type=<object object>, **kwargs)¶
Bases:
schrodinger.models.parameters.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[schrodinger.tasks.tasks.AbstractTask]¶
A list param that contains
CompoundParam
instances. Signals will be emitted any time an item in the list changes or the contents of the list itself change. See_SignalContainer
and_PLPSignalContainer
for information on specific signals.
- failed_tasks: List[schrodinger.tasks.tasks.AbstractTask]¶
A list param that contains
CompoundParam
instances. Signals will be emitted any time an item in the list changes or the contents of the list itself change. See_SignalContainer
and_PLPSignalContainer
for information on specific signals.
- __len__() int ¶
- addTasks(tasks: List[schrodinger.tasks.tasks.AbstractTask]) None ¶
- makeReport() schrodinger.tasks.queue.QueueReport ¶
- DataClass¶
This class can be used to declare a public attribute on a
CompoundParam
. Declared public attributes can be used without error.Example usage:
class Coord(CompoundParam): x: int y: int note = NonParamAttribute() coord = Coord() coord.note = "hello" # No error
- __init__(default_value=<object object>, _param_type=<object object>, **kwargs)¶
- classmethod addSubParam(name, param, update_owner=True)¶
- blockSignals(self, b: bool) bool ¶
- block_signal_propagation()¶
- childEvent(self, a0: QChildEvent)¶
- children(self) List[QObject] ¶
- classmethod configureParam()¶
Override this class method to set up the abstract param class (e.g. setParamReference on child params.)
- connectNotify(self, signal: QMetaMethod)¶
- customEvent(self, a0: QEvent)¶
- classmethod defaultValue()¶
Returns the default value for this abstract param:
default_atom = Atom.defaultValue() assert Atom.coord.x == 0
- deleteLater(self)¶
- destroyed¶
destroyed(self, object: typing.Optional[QObject] = None) [signal]
- disconnect(a0: QMetaObject.Connection) bool ¶
- disconnect(self) None
- disconnectNotify(self, signal: QMetaMethod)¶
- done_tasksChanged¶
- done_tasksReplaced¶
- dumpObjectInfo(self)¶
- dumpObjectTree(self)¶
- dynamicPropertyNames(self) List[QByteArray] ¶
- event(self, a0: QEvent) bool ¶
- eventFilter(self, a0: QObject, a1: QEvent) bool ¶
- failed_tasksChanged¶
- failed_tasksReplaced¶
- 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]
- classmethod fromJson(json_obj)¶
A factory method which constructs a new object from a given dict loaded from a json string or file.
- Parameters
json_obj (dict) – A json-loaded dictionary to create an object from.
- Returns
An instance of this class.
- Return type
cls
- classmethod fromJsonImplementation(json_dict)¶
Sets the value of this compound param value object from a JSON dict.
Warning
This should never be called directly.
- getAbstractParam()¶
Return the corresponding abstract param for this instance.
- classmethod getJsonBlacklist()¶
Override to customize what params are serialized.
Implementations should return a list of abstract params that should be omitted from serialization.
- ..NOTE
Returned abstract params must be direct child params of
cls
, e.g.cls.name
, notcls.coord.x
.
- classmethod getParamSignal(obj, signal_type='Changed')¶
- classmethod getParamValue(obj)¶
Enables access to a param value on a compound param via an abstract param reference:
a = Atom() assert Atom.coord.x.getParamValue(a) == 0 # ints default to 0 a.coord.x = 3 assert Atom.coord.x.getParamValue(a) == 3
- Parameters
param (CompoundParam) – The owner param to get a param value from
- classmethod getSubParam(name)¶
Get the value of a subparam using the string name:
c = Coord() assert c.getSubParam('x') == 0
Note
Using the string name to access params is generally discouraged, but can be useful for serializing/deserializing param data.
- Parameters
name (str) – The name of the subparam to get the value for.
- classmethod getSubParams()¶
Return a dictionary mapping subparam names to their values.
- getTypeHint()¶
- get_version()¶
Method to get the version of a particular object. Defaults to the current version of mmshare. This class can be overridden for custom versioning behavior.
- inherits(self, classname: str) bool ¶
- initAbstract()¶
- initConcrete()¶
Override to customize initialization of concrete params.
- initializeValue()¶
Override to dynamically set up the default value of the param. Useful for default values that are determined at runtime. This is called any time the param is reset.
- installEventFilter(self, a0: QObject)¶
- classmethod isAbstract()¶
Whether the param is an “abstract” param.
- isDefault()¶
Whether the current value of this instance matches the default value.
- isSignalConnected(self, signal: QMetaMethod) bool ¶
- isWidgetType(self) bool ¶
- isWindowType(self) bool ¶
- killTimer(self, id: int)¶
- metaObject(self) QMetaObject ¶
- moveToThread(self, thread: QThread)¶
- objectName(self) str ¶
- objectNameChanged¶
objectNameChanged(self, objectName: str) [signal]
- classmethod owner()¶
Get the owner of the param:
# Can be called on an abstract param: assert Coord.x.owner() == Coord # ...or on an instance of a CompoundParam a = Atom() assert a.coord.owner() == a
- classmethod ownerChain()¶
Returns a list of param owners starting from the toplevel param and ending with self. Examples:
foo.bar.atom.coord.ownerChain()
will return[foo, bar, atom, coord]
where every item is a concrete param.Foo.bar.atom.coord.x.ownerChain()
will return[Foo, Foo.bar, Foo.atom.coord, Foo.atom.coord.x]
where every item is an abstract params.
- classmethod paramName()¶
Get the name of the param:
# Can be called on an abstract param: print(Coord.x.paramName()) # 'x' # ...or on an instance of a CompoundParam a = Atom() a.coord.paramName() # 'coord'
- parent(self) QObject ¶
- property(self, name: str) Any ¶
- 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.
- receivers(self, signal: PYQT_SIGNAL) int ¶
- removeEventFilter(self, a0: QObject)¶
- reset(*abstract_params)¶
Resets this compound param to its default value:
class Line(CompoundParam): start = Coord(x=1, y=2) end = Coord(x=4, y=5) line = Line() line.start.x = line.end.x = 10 assert line.start.x == line.end.x == 10 line.reset() assert line.start.x == 1 assert line.end.x == 4
Any number of abstract params may be passed in to perform a partial reset of only the specified params:
line.start.x = line.end.x = 10 line.reset(Line.start.x) # resets just start.x assert line.start.x == 1 assert line.end.x == 10 line.reset(Line.end) # resets the entire end point assert line.end.x == 4 line.start.y = line.end.y = 10 line.reset(Line.start.y, Line.end.y) # resets the y-coord of both assert line.start.y == 2 assert line.end.y == 5
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setObjectName(self, name: str)¶
- classmethod setParamValue(obj, value)¶
Set the value of a param on an object by specifying the instance and the value:
# Setting the param value of a basic param a = Atom() Atom.coord.x.setParamValue(a, 5) assert a.coord.x == 5 # setParamValue can also be used to set the value of CompoundParams c = Coord() c.x = 10 atom.coord.setParamValue(a, c) assert atom.coord.x == 10
- Parameters
param – The owner param to set a subparam value of.
value – The value to set the subparam value to.
- setParent(self, a0: QObject)¶
- setProperty(self, name: str, value: Any) bool ¶
- classmethod setReference(param1, param2)¶
Call this class method from configureParam to indicate that two params should be kept in sync. The initial values will start with the default value of
param1
. Example:class Square(CompoundParam): width: float = 5 height: float = 10 @classmethod def configureParam(cls): super().configureParam() cls.setReference(cls.width, cls.height) square = Square() assert square.width == square.height == 5 # Default value of width # takes priority square.height = 7 assert square.width == square.height == 7 square.width = 6 assert square.width == square.height == 6
- Parameters
param1 – The first abstract param to keep synced
param2 – The second abstract param. After instantiation, this param will take on the value of param1.
- setValue(value=None, **kwargs)¶
Set the value of this
CompoundParam
to matchvalue
.- Parameters
value – The value to set this
CompoundParam
to. It should be the same type as thisCompoundParam
.kwargs – For internal use only.
- signalsBlocked(self) bool ¶
- skip_eq_check()¶
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int ¶
- staticMetaObject = <PyQt6.QtCore.QMetaObject object>¶
- thread(self) QThread ¶
- timerEvent(self, a0: QTimerEvent)¶
- toDict()¶
Return a dictionary version of this
CompoundParam
. The returned dictionary is fully nested and contains noCompoundParam
instancesa = Atom() a_dict = a.toDict() assert a_dict['coord']['x'] == 0 assert a_dict['coord'] == {'x':0, 'y':0}
- toJson(_mark_version=True)¶
Create and returns a data structure made up of jsonable items.
- Return type
An instance of one the classes from NATIVE_JSON_DATATYPES
- toJsonImplementation()¶
Returns a JSON representation of this value object.
Warning
This should never be called directly.
- tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str ¶
- valueChanged¶
- class schrodinger.tasks.queue.TaskQueue(*args, _param_type=<object object>, **kwargs)¶
Bases:
schrodinger.tasks.tasks.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¶
- queueDone¶
- max_running_tasks: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- __init__(*args, **kwargs)¶
- addTask(task)¶
- getTasks()¶
Return all tasks in the queue.
- Return type
tuple[tasks.AbstractTask]
- setUpMain()¶
- AUTO_TASKDIR = 1¶
- CMDLINE = 1¶
- DEFAULT_TASKDIR_SETTING = None¶
- DONE = 3¶
- DataClass¶
This class can be used to declare a public attribute on a
CompoundParam
. Declared public attributes can be used without error.Example usage:
class Coord(CompoundParam): x: int y: int note = NonParamAttribute() coord = Coord() coord.note = "hello" # No error
- FAILED = 2¶
- GUI = 2¶
- INTERRUPT_ENABLED = False¶
- RUNNING = 1¶
- TEMP_TASKDIR = 2¶
- WAITING = 0¶
- addFuncToGroup(func, group=None, order=None)¶
Adds a function to the specified chain. Typically used for adding functions that are not methods of this object.
The function may optionally be decorated with a FuncGroupMarker. If so, the default group and order will be determined by the decorator. Any group or order explicitly passed in to addFuncToGroup will take precedence over the decorator settings.
- Parameters
func – the function to add
group (FuncGroupMarker or None) – the group marker. If the function is decorated with a FuncGoupMarker, that group marker will be the default.
order (float or None) – the sorting order. If the function is decorated with a FuncGoupMarker, the order specified in the decorator will be the default.
- addLicenseReservation(license, num_tokens=1)¶
Add a license reservation for this job. This information is used by job control to ensure the job is only started once the required licenses become available.
In a preprocessor, (i.e. before launching the backend), a reservation should be added for each license that will be checked out directly by that backend. Example:
class GlideTask(ComboJobTask): @preprocessor def _reserveGlideLicense(self): # Reserve a Glide license. self.addLicenseReservation(license.GLIDE_MAIN) def mainFunction(self): # Check out the Glide license lic = license.License(license.GLIDE_MAIN) # ... Do computations requiring Glide ... lic.checkin()
Licenses that will be checked out by subjobs of this job do not need reservations added here; subjobs are responsible for their own license reservations.
- Parameters
license (module-constant from schrodinger.utils.license (e.g. license.AUTODESIGNER)) – a license that will be used by the backend
num_tokens (int) – number of tokens for this license reservations
- addPostprocessor(func, order=0)¶
Adds a postproceessor function to this task instance. If the function has been decorated with
@postprocessor
, the order specified by the decorator will be used.- Parameters
func (typing.Callable) – the function to add
order (float) – the sorting order for the function relative to all other preprocessors. Takes precedence over order specified by the preprocessor decorator.
- addPreprocessor(func, order=None)¶
Adds a preproceessor function to this task instance. If the function has been decorated with @preprocessor, the order specified by the decorator will be used as the default.
- Parameters
func – the function to add
order (float) – the sorting order for the function relative to all other preprocessors. Takes precedence over order specified by the preprocessor decorator.
- classmethod addSubParam(name, param, update_owner=True)¶
- blockSignals(self, b: bool) bool ¶
- block_signal_propagation()¶
- calling_context: CallingContext¶
- calling_contextChanged¶
- calling_contextReplaced¶
- childEvent(self, a0: QChildEvent)¶
- children(self) List[QObject] ¶
- classmethod configureParam()¶
Override this class method to set up the abstract param class (e.g. setParamReference on child params.)
- connectNotify(self, signal: QMetaMethod)¶
- customEvent(self, a0: QEvent)¶
- classmethod defaultValue()¶
Returns the default value for this abstract param:
default_atom = Atom.defaultValue() assert Atom.coord.x == 0
- 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] ¶
- event(self, a0: QEvent) bool ¶
- eventFilter(self, a0: QObject, a1: QEvent) bool ¶
- failure_info: FailureInfo¶
Dataclass for task failure information.
Printing an instance of this class will provide the minimum necessary human-readable representation of a recorded failure.
- failure_infoChanged¶
- failure_infoReplaced¶
- 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]
- classmethod fromJson(json_obj)¶
A factory method which constructs a new object from a given dict loaded from a json string or file.
- Parameters
json_obj (dict) – A json-loaded dictionary to create an object from.
- Returns
An instance of this class.
- Return type
cls
- classmethod fromJsonFilename(filename)¶
- classmethod fromJsonImplementation(json_dict)¶
Sets the value of this compound param value object from a JSON dict.
Warning
This should never be called directly.
- getAbstractParam()¶
Return the corresponding abstract param for this instance.
- getAddedFuncs(group=None)¶
- getDebugString()¶
- getFuncGroup(group=None)¶
Retrieve the functions belonging to the specified group.
- Parameters
group (FuncGroupMarker) – the group marker
- Returns
the functions in the specified group, in order
- Return type
list
- classmethod getJsonBlacklist()¶
Override to customize what params are serialized.
Implementations should return a list of abstract params that should be omitted from serialization.
- ..NOTE
Returned abstract params must be direct child params of
cls
, e.g.cls.name
, notcls.coord.x
.
- classmethod getParamSignal(obj, signal_type='Changed')¶
- classmethod getParamValue(obj)¶
Enables access to a param value on a compound param via an abstract param reference:
a = Atom() assert Atom.coord.x.getParamValue(a) == 0 # ints default to 0 a.coord.x = 3 assert Atom.coord.x.getParamValue(a) == 3
- Parameters
param (CompoundParam) – The owner param to get a param value from
- classmethod getSubParam(name)¶
Get the value of a subparam using the string name:
c = Coord() assert c.getSubParam('x') == 0
Note
Using the string name to access params is generally discouraged, but can be useful for serializing/deserializing param data.
- Parameters
name (str) – The name of the subparam to get the value for.
- classmethod getSubParams()¶
Return a dictionary mapping subparam names to their values.
- getTaskDir()¶
Returns the full path of the task directory. This is only available if the task directory exists (after creation of the taskdir or, if no task dir is specified, any time).
- getTaskFilename(fname)¶
Return the appropriate absolute path for an input or output file in the taskdir.
- getTypeHint()¶
- get_version()¶
Method to get the version of a particular object. Defaults to the current version of mmshare. This class can be overridden for custom versioning behavior.
- guard()¶
Context manager that saves any Exception raised inside
- static guard_method(func)¶
- inherits(self, classname: str) bool ¶
- initAbstract()¶
- initConcrete()¶
Override to customize initialization of concrete params.
- initializeValue()¶
@overrides: parameters.CompoundParam
- input: parameters.CompoundParam¶
All
CompoundParam
instances are automatically serializable if their subparams are serializable. To serialize and deserialize, use the schrodinger json module:from schrodinger.models import json class Coord(parameters.CompoundParam): x: int y: int c1 = Coord(x=1, y=2) c1_string = json.dumps(c1) c2 = json.loads(c1_string, DataClass=Coord) assert c1 == c2
- inputChanged¶
- inputReplaced¶
- installEventFilter(self, a0: QObject)¶
- classmethod isAbstract()¶
Whether the param is an “abstract” param.
- isDebugEnabled()¶
- isDefault()¶
Whether the current value of this instance matches the default value.
- isInterruptionRequested()¶
- isRunning()¶
- isSignalConnected(self, signal: QMetaMethod) bool ¶
- isStartable()¶
- isWidgetType(self) bool ¶
- isWindowType(self) bool ¶
- kill()¶
Implementations are responsible for immediately stopping the task. No threads or processes should be running after this method is complete.
This method should be called sparingly since in many contexts the task will be forced to terminate without a chance to clean up or free resources.
- killTimer(self, id: int)¶
- mainDone¶
- max_progress: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- max_progressChanged¶
- max_progressReplaced¶
- max_running_tasksChanged¶
- max_running_tasksReplaced¶
- metaObject(self) QMetaObject ¶
- moveToThread(self, thread: QThread)¶
- name: str¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- nameChanged¶
- nameReplaced¶
- objectName(self) str ¶
- objectNameChanged¶
objectNameChanged(self, objectName: str) [signal]
- output: parameters.CompoundParam¶
All
CompoundParam
instances are automatically serializable if their subparams are serializable. To serialize and deserialize, use the schrodinger json module:from schrodinger.models import json class Coord(parameters.CompoundParam): x: int y: int c1 = Coord(x=1, y=2) c1_string = json.dumps(c1) c2 = json.loads(c1_string, DataClass=Coord) assert c1 == c2
- outputChanged¶
- outputReplaced¶
- classmethod owner()¶
Get the owner of the param:
# Can be called on an abstract param: assert Coord.x.owner() == Coord # ...or on an instance of a CompoundParam a = Atom() assert a.coord.owner() == a
- classmethod ownerChain()¶
Returns a list of param owners starting from the toplevel param and ending with self. Examples:
foo.bar.atom.coord.ownerChain()
will return[foo, bar, atom, coord]
where every item is a concrete param.Foo.bar.atom.coord.x.ownerChain()
will return[Foo, Foo.bar, Foo.atom.coord, Foo.atom.coord.x]
where every item is an abstract params.
- classmethod paramName()¶
Get the name of the param:
# Can be called on an abstract param: print(Coord.x.paramName()) # 'x' # ...or on an instance of a CompoundParam a = Atom() a.coord.paramName() # 'coord'
- parent(self) QObject ¶
- postprocessors()¶
- Returns
A list of postprocessors, both decorated methods on the task and external functions that have been added via
addPostprocessor()
- Return type
list[typing.Callable]
- preprocessors()¶
- Returns
A list of preprocessors (both decorated methods on the task and external functions that have been added via addPreprocessor)
- printDebug(*args)¶
- processFuncChain(chain=None, result_callback=None)¶
Execute each function in the specified chain sequentially in order.
The result_callback is called after each function with the return value of that function. This can be used to respond to the return value (e.g. present information to the user, get user feedback, log the result, etc.)
The return value of the result_callback determines whether processing will proceeed to the next function.
- Parameters
chain (FuncChainDecorator) – which chain to process
result_callback – the callback that will get called with the result of each function in the chain
- Returns
a list of the results from the functions
- progress: int¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- progressChanged¶
- progressReplaced¶
- progress_string: str¶
Base class for all Param classes. A Param is a descriptor for storing data, which means that a single Param instance will manage the data values for multiple instances of the class that owns it. Example:
class Coord(CompoundParam): x: int y: int
An instance of the Coord class can be created normally, and Params can be accessed as normal attributes:
coord = Coord() coord.x = 4
When a Param value is set, the
valueChanged
signal is emitted. Params can be serialized and deserialized to and from JSON. Params can also be nested:class Atom(CompoundParam): coord: Coord element: str
- progress_stringChanged¶
- progress_stringReplaced¶
- property(self, name: str) Any ¶
- 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.
- receivers(self, signal: PYQT_SIGNAL) int ¶
- removeEventFilter(self, a0: QObject)¶
- replicate()¶
Create a new task with the same input and settings (but no output)
- requestInterruption()¶
Request the task to stop.
To enable this feature, subclasses should periodically check whether an interruption has been requested and terminate if it has been. If such logic has been included,
INTERRUPT_ENABLED
should be set toTrue
.
- reset(*args, **kwargs)¶
Resets this compound param to its default value:
class Line(CompoundParam): start = Coord(x=1, y=2) end = Coord(x=4, y=5) line = Line() line.start.x = line.end.x = 10 assert line.start.x == line.end.x == 10 line.reset() assert line.start.x == 1 assert line.end.x == 4
Any number of abstract params may be passed in to perform a partial reset of only the specified params:
line.start.x = line.end.x = 10 line.reset(Line.start.x) # resets just start.x assert line.start.x == 1 assert line.end.x == 10 line.reset(Line.end) # resets the entire end point assert line.end.x == 4 line.start.y = line.end.y = 10 line.reset(Line.start.y, Line.end.y) # resets the y-coord of both assert line.start.y == 2 assert line.end.y == 5
- run()¶
- runPreprocessing(callback=None, calling_context=None)¶
Run the preprocessors one-by-one. By default, any failing preprocessor will raise a TaskFailure exception and terminate processing. This behavior may be customized by supplying a callback function which will be called after each preprocessor with the result of that preprocessor.
This method is “final” so that all preprocessing logic will be enclosed in the try/finally block.
- Parameters
callback – a function that takes result and returns a bool that indicates whether to continue on to the next preprocessor
calling_context – specify a value here to indicate the context in which this preprocessing is being called. This value will be stored in an instance variable, self.calling_context, which can be accessed from any preprocessor method on this task. Typically this value will be either self.GUI, self.CMDLINE, or None, but any value may be supplied here and checked for in the preprocessor methods. self.calling_context always reverts back to None at the end of runPreprocessing.
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setObjectName(self, name: str)¶
- classmethod setParamValue(obj, value)¶
Set the value of a param on an object by specifying the instance and the value:
# Setting the param value of a basic param a = Atom() Atom.coord.x.setParamValue(a, 5) assert a.coord.x == 5 # setParamValue can also be used to set the value of CompoundParams c = Coord() c.x = 10 atom.coord.setParamValue(a, c) assert atom.coord.x == 10
- Parameters
param – The owner param to set a subparam value of.
value – The value to set the subparam value to.
- setParent(self, a0: QObject)¶
- setProperty(self, name: str, value: Any) bool ¶
- classmethod setReference(param1, param2)¶
Call this class method from configureParam to indicate that two params should be kept in sync. The initial values will start with the default value of
param1
. Example:class Square(CompoundParam): width: float = 5 height: float = 10 @classmethod def configureParam(cls): super().configureParam() cls.setReference(cls.width, cls.height) square = Square() assert square.width == square.height == 5 # Default value of width # takes priority square.height = 7 assert square.width == square.height == 7 square.width = 6 assert square.width == square.height == 6
- Parameters
param1 – The first abstract param to keep synced
param2 – The second abstract param. After instantiation, this param will take on the value of param1.
- setValue(value=None, **kwargs)¶
Set the value of this
CompoundParam
to matchvalue
.- Parameters
value – The value to set this
CompoundParam
to. It should be the same type as thisCompoundParam
.kwargs – For internal use only.
- signalsBlocked(self) bool ¶
- skip_eq_check()¶
- specifyTaskDir(taskdir_spec)¶
Specify the taskdir creation behavior. Use one of the following options:
A directory name (string). This may be a relative or absolute path
None - no taskdir is requested. The task will use the CWD as its taskdir
AUTO_TASKDIR - a new subdirectory will be created in the CWD using the task name as the directory name.
TEMP_TASKDIR - a temporary directory will be created in the schrodinger temp dir. This directory is cleaned up when the task is deleted.
- Parameters
taskdir_spec – one of the four options listed above
- start(skip_preprocessing=False)¶
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.
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int ¶
- staticMetaObject = <PyQt6.QtCore.QMetaObject object>¶
- status: Status¶
- statusChanged¶
- statusReplaced¶
- taskDirSetting()¶
Returns the taskdir spec. See specifyTaskDir() for details.
- taskDone¶
- taskFailed¶
- taskStarted¶
- thread(self) QThread ¶
- timerEvent(self, a0: QTimerEvent)¶
- toDict()¶
Return a dictionary version of this
CompoundParam
. The returned dictionary is fully nested and contains noCompoundParam
instancesa = Atom() a_dict = a.toDict() assert a_dict['coord']['x'] == 0 assert a_dict['coord'] == {'x':0, 'y':0}
- toJson(_mark_version=True)¶
Create and returns a data structure made up of jsonable items.
- Return type
An instance of one the classes from NATIVE_JSON_DATATYPES
- toJsonImplementation()¶
Returns a JSON representation of this value object.
Warning
This should never be called directly.
- tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str ¶
- valueChanged¶
- wait(timeout=None)¶
Block until the task is finished executing or
timeout
seconds have passed.Warning
This should not be called directly from GUI code - see PANEL-18317. It is safe to call inside a subprocess or job. Run
git grep "task.wait("
to see safe examples annotated with “# OK”.- Parameters
timeout (NoneType or int) – Amount of time in seconds to wait before timing out. If None or a negative number, this method will wait until the task is finished.
- class schrodinger.tasks.queue.TaskDJ(*args, task_timeout=None, **kwargs)¶
Bases:
schrodinger.job.queue.JobDJ
WARNING: This class is slated for removal. To run tasks in parallel, consider using the
run_tasks_in_parallel
below, or else use JobDJ directly by using task.runToCmd and task.setJobA subclass of JobDJ that supports running tasks.
NOTE: In order for remote jobs to be distributed properly, ensure that task.job_config.host_settings.host is set to None, otherwise TaskDJ will not add a -HOST option.
- __init__(*args, task_timeout=None, **kwargs)¶
Constructor.
- Parameters
hosts – A list of hosts to run on. Items of the list can be a (<hostname>, <maximum_concurrent_subjobs>) tuple that gives a host name and the maximum number of processors that can be used on that host. Or, items of the list can be a
ResourceHost
object that provides a detailed listing of the number of processors on each host that can be used for jobs requesting specific resources. The list can mix tuple andResourceHost
items. If a host appears more than once (whether as a tuple orResourceHost
), the information in the multiple entries is added together. Processors in the tuple form are only considered usable by jobs that have resource_requirement=None (The default state for jobs). The default value of None for this parameter means the host information is determined automatically from the command line and is usually desired.local – No longer functional in JOB_SERVER.
max_retries – Number of allowed retries per subjob. If this is set, it is never overridden by the
SCHRODINGER_MAX_RETRIES
environment variable. If it is not set, the value in default_max_retries is used, andSCHRODINGER_MAX_RETRIES
is allowed to override. If you wish to disable restarting altogether, set this value to zero.default_max_retries – Number of allowed retries per subjob. This value can always be overridden by the
SCHRODINGER_MAX_RETRIES
environment variable. Default is zero.max_failures – Total number of allowed subjob failures before
JobDJ
exits. If it is not defined, a default of zero will be used (exit on any failure after attempting to restart), but this can be overridden with theSCHRODINGER_MAX_FAILURES
environment variable. To allow an unlimited number of subjob failures, set max_failures to the module level NOLIMIT constant.verbosity – There are three allowed verbosity levels: “quiet” - only warnings and errors are printed; “normal” -
JobDJ
progress is printed; and “verbose” - additional debugging info is printed. Default is “quiet”.job_class – The class to use as the default job constructor when the
addJob
argument is not aBaseJob
instance.update_delay – The number of seconds to wait between job control database reads for
JobControlJob
jobs. (This delay is for an individual job, not for any job database read.) Default is None, which causes the module level constant UPDATE_DELAY to be used.smart_dist_resources – Custom resources that the localhost provides for smart distribution. Jobs that require a custom resource that is not included in this list will not be run on the localhost even if smart distribution is turned on. This information is unused if smart distribution is off. Each item of the list is a string that defines a custom resource.
- Raises
HostTypeError – if the host argument or one of its items is of the wrong type
- addTask(task)¶
- updatedTasks()¶
- property active_jobs: List[schrodinger.job.queue.BaseJob]¶
- addJob(job: Union[schrodinger.job.queue.BaseJob, List], add_connected: bool = True, **kwargs)¶
Add a job to run. If
job
is not aBaseJob
instance, aBaseJob
instance is constructed withjob
as the first argument. The defaultBaseJob
class for theJobDJ
instance can be specified in the constructor forJobDJ
.Additional keyword arguments are passed on to the job constructor.
All job prerequisites and dependencies need to be specified before adding a job to
JobDJ
.- Parameters
add_connected – If True, for jobs with dependencies only one job per connected group should be added and all connected jobs will be discovered and added automatically. If False, it is the user’s responsibility to make sure that any prerequisites of a job are also added.
- property all_jobs: List[schrodinger.job.queue.BaseJob]¶
- static createResourceHost(host_info: Tuple[str, int], resource: Optional[str] = None) schrodinger.job.queue.ResourceHost ¶
Given a tuple of (hostname, procs), return a ResourceHost.
- Parameters
host_info (tuple) – The hostname and number of processors it has
resource (str) – The resource the host provides, if any. If not given, the host will only run jobs that have no resource_requirement.
- Return type
- Returns
The ResourceHost created from in the input data
- Raises
HostTypeError – If the provided host_info has the wrong format
- disableSmartDistribution()¶
Disable smart distribution of jobs.
Smart distribution allows subjobs to run on the machine that JobDJ is running on when JobDJ itself is running under a queuing system. This is usually desirable since the JobDJ process doesn’t generally consume significant computational resources and you don’t want to leave a queue slot mostly idle.
- property done_jobs: List[schrodinger.job.queue.BaseJob]¶
Successfully completed jobs, sorted into the order they were marked as completed by JobDJ.
- dump(filename: pathlib.Path)¶
Pickle the
JobDJ
instance to the specified file name.
- property failed_jobs: List[schrodinger.job.queue.BaseJob]¶
- getActiveProcCounts() Dict[str, int] ¶
Return a dictionary containing the number of active jobs on each host.
Any resource requirement of the active jobs is ignored.
- getActiveProcsOnHost(hostname: str, requirement: Optional[Union[str, schrodinger.job.resource.ComputeType]]) int ¶
Get the current number of processors on the given host that are currently occupied by jobs that request the given requirement
- Parameters
hostname – The host to check
requirement – The job requirement to check
- Returns
The number of currently used processors on hostname that provide requirement
- getFirstHost()¶
Get first host from the lists of hosts.
- Return type
str
- Returns
First host
- hasStarted() bool ¶
Returns True if JobDJ has started already
- isComplete() bool ¶
Returns True if JobDJ has completed, False otherwise.
- killJobs()¶
Kill all active jobs
- markForRestart(job: schrodinger.job.queue.BaseJob, action: str)¶
Mark a job as dead, but make sure that it gets restarted.
- Parameters
action – Describes the reason the job is being restarted.
- printStatus(job: Optional[schrodinger.job.queue.BaseJob] = None, action: Optional[str] = None)¶
Prints the status of
JobDJ
and the action/status for the job.If no job is specified, prints the status header.
If no action is specified, the
status_string
attribute of the job is used.
- run(*, status_change_callback: Optional[Callable[[schrodinger.job.queue.BaseJob], None]] = None, periodic_callback: Optional[Callable[[schrodinger.job.queue.BaseJob], None]] = None, callback_interval: int = 300, restart_failed: bool = True)¶
Call this method to run all jobs that have been added. The method will return control when all jobs have completed.
- Parameters
status_change_callback – A function to call every time a job status changes. For example, JobState.RUNNING->JobState.DONE. This function takes a single argument of a schrodinger.job.queue.BaseJob object.
periodic_callback – A command to call periodically, regardless of whether job status has changed or not. The function will be called without any arguments.
callback_interval – The interval at which the periodic interval will be called. This time is only approximately enforced and will depend on the timing delay settings (e.g. MONITOR_DELAY).
restart_failed – True (default) if previously failed jobs should be restarted, False if not.
- setHostList(host_list: List[Union[Tuple[str, int], schrodinger.job.queue.ResourceHost]])¶
Define compute hosts to run subjobs on.
Active jobs are not affected by a change in the host list.
- Parameters
host_list – A list of hosts to run on. See the documentation for the hosts parameter to the __init__ method of this class for additional information.
- Raises
HostTypeError – If one of the host_list items is not of the correct type
- setSmartDistribution(state: bool)¶
Set smart distribution of jobs.
- Parameters
state (bool) – Whether to enable smart distribution
- property total_active: int¶
The number of jobs currently running.
- property total_added: int¶
The number of individual jobs that have been added to the JobDJ instance.
- property total_failed: int¶
The number of jobs that have failed.
- property total_finished: int¶
The number of jobs that have finished successfully.
- property waiting_jobs: List[schrodinger.job.queue.BaseJob]¶
Jobs waiting to be started.
- class schrodinger.tasks.queue.AutoFileMode(value)¶
Bases:
enum.IntEnum
An enumeration.
- 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)¶
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
- Returns
the queue results, which can be used to generate a queue report.
- Return type
- schrodinger.tasks.queue.run_tasks_on_queue(task_list, autoname=True, basename=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, auto_file_mode=AutoFileMode.FAILED_LOG, dj_init_kwargs: Optional[dict] = None, dj_addJob_kwargs: Optional[dict] = None, dj_run_kwargs: Optional[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.See
run_tasks_in_parallel
for details on more params.- Parameters
dj (schrodinger.job.queue.JobDJ) – A JobDJ to run the tasks on. This is optional and useful if want a jobdj with specific settings.
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.
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.setup_dj_tasks(task_list, dj=None, autoname=True, basename=None, addJob_kwargs: Optional[dict] = None)¶
Sets up a JobDJ with a collection of tasks. See run_tasks_on_dj for details.
If task.job_config.host_settings.host is set to either None or localhost, JobDJ will automatically choose the host (generally recommended behavior). Setting the host to anything else will override the automatic behavior. If JobDJ’s automatic host is not localhost already, there is no way to force it to choose localhost.
- Parameters
addJob_kwargs – A dictionary of keyword arguments to pass to
JobDJ.addJob
for each jobtask.
- 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.auto_register_files(task_list, auto_file_mode=AutoFileMode.FAILED_LOG)¶
Automatically registers files from the subtask with the parent job (if applicable).