schrodinger.maestro_utils.maestro_sync module

class schrodinger.maestro_utils.maestro_sync.BaseMaestroSync(*args, **kwargs)

Bases: object

Basic Maestro synchronization class that can be used as infrastructure for responding to specific events with the Maestro project and Workspace.

Variables
  • _cb_type_callback_map (set[str, set[Callable]]) – a dictionary mapping callback types to the set of callback functions associated with that type

  • _callbacks_active (bool) – whether the stored callbacks should be registered at this time

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

addProjectUpdateCallback(callback_fn)

Add function to list of “project updated” callbacks.

Parameters

callback_fn (Callable) – the function to add

addProjectCloseCallback(callback_fn)

Add function to list of “project closed” callbacks.

Parameters

callback_fn (Callable) – the function to add

addWorkspaceChangeCallback(callback_fn)

Add function to list of “workspace changed” callbacks.

Parameters

callback_fn (Callable) – the function to add

setCallbacksActive(active)

Register or deregister all callbacks. When activating, call all “project updated” callbacks.

Parameters

active (bool) – whether to register or deregister callbacks with Maestro

suspendCallbacks()

Context manager to temporarily disable Maestro callbacks.

onProjectUpdated()

Callback method for project update events. Should be overridden in concrete subclasses to add functionality.

onProjectClosed()

Callback method for project close events. Should be overridden in concrete subclasses to add functionality.

onWorkspaceChanged(what_changed)

Callback method for workspace change events. Should be overridden in concrete subclasses to add functionality.

Parameters

what_changed (str) – the kind of change that occurred in the Workspace; will be one of the WORKSPACE_CHANGED_ constants in maestro.py

schrodinger.maestro_utils.maestro_sync.requires_structure_getter(method, self, *args, **kwargs)

Decorator for ProjectEntryMaestroSync methods that raises an exception if the decorated method is called when the structure getter is undefined.

class schrodinger.maestro_utils.maestro_sync.ProjectEntryMaestroSync(parent=None, group_name=None, parent_group_name=None)

Bases: schrodinger.maestro_utils.maestro_sync.BaseMaestroSync, PyQt5.QtCore.QObject

Maestro sync class that acts as an interface with project entries.

If the user has a ParamListParam (PLP) or multiple PLPs that they wish to have correspond with entries in the project, they can assign them as the models for one or more of the targets associated with this class:

  1. entry_plp_target: creates and tracks entries associated with

    items in the model PLP. If the user wishes to use any of the subsequent targets, they must first assign a model for this target.

  2. group_plp_target: moves associated entries into an entry group

  3. select_plp_target: selects associated entries

  4. include_plp_target: includes associated entries

In addition to assigning model PLPs to the above targets, the user must also assign a function that can return a structure from a PLP item using the setStructureGetter() method. A simple example would just be:

mae_sync = ProjectEntryMaestroSync()
mae_sync.setStructureGetter(lambda item: item.structure)

Finally, the user may also assign a StringParam model that tracks the title for the entry group created for the group_plp_target model.

Variables
  • _structure_getter (callable) – the function used to access structure objects from PLP items

  • _st_eid_map (dict[structure.Structure, str]) – a dictionary mapping structures to their corresponding entry IDs

__init__(parent=None, group_name=None, parent_group_name=None)
Parameters
  • parent (QtCore.QObject) – the parent for this object

  • group_name (str or NoneType) – a custom name for the entry group tracked by group_plp_target

  • parent_group_name (str) – the parent group name for the entry group tracked by group_plp_target, if it is meant to be a subgroup

setStructureGetter(getter)

Assign the function that can be used by the PLP targets on this class to retrieve structure objects from items on the PLP, e.g.

plp = self.entry_plp_target.getPLP() for item in plp:

st = self._structure_getter(item)

This getter must be set in order for this class to function.

Parameters

getter (callable) – a function that will return a structure object from a PLP item

groupName()
Returns

the entry group name associated with this class

Return type

str

onProjectUpdated()

Respond to the project updating by searching for entries associated with the project entry PLP. If any have been deleted from the project, remove the associated model PLP items.

addProjectCloseCallback(callback_fn)

Add function to list of “project closed” callbacks.

Parameters

callback_fn (Callable) – the function to add

addProjectUpdateCallback(callback_fn)

Add function to list of “project updated” callbacks.

Parameters

callback_fn (Callable) – the function to add

addWorkspaceChangeCallback(callback_fn)

Add function to list of “workspace changed” callbacks.

Parameters

callback_fn (Callable) – the function to add

blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

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

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

onProjectClosed()

Callback method for project close events. Should be overridden in concrete subclasses to add functionality.

onWorkspaceChanged(what_changed)

Callback method for workspace change events. Should be overridden in concrete subclasses to add functionality.

Parameters

what_changed (str) – the kind of change that occurred in the Workspace; will be one of the WORKSPACE_CHANGED_ constants in maestro.py

parent(self) → QObject
property(self, 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, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setCallbacksActive(active)

Register or deregister all callbacks. When activating, call all “project updated” callbacks.

Parameters

active (bool) – whether to register or deregister callbacks with Maestro

setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
suspendCallbacks()

Context manager to temporarily disable Maestro callbacks.

thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = - 1) → str
class schrodinger.maestro_utils.maestro_sync.PLPTarget(parent=None)

Bases: schrodinger.models.mappers.TargetMixin, PyQt5.QtCore.QObject

A generic target for a PLP model.

Variables

PLPMutated (QtCore.pyqtSignal) – a signal that propagates the ParamListParam.mutated signal from the model PLP

PLPMutated
__init__(parent=None)

Initialize self. See help(type(self)) for accurate signature.

targetGetValue()
targetSetValue(value)
getPLP()
Returns

the PLP model for this target, if one has been defined

Return type

parameters.ParamListParam or NoneType

setPLP(plp)

Assign a new PLP model.

Raises

TypeError – if an invalid parameter is supplied

Parameters

plp (parameters.ParamListParam or NoneType) – a PLP containing structures, or None

auto_update_model = True
auto_update_target = True
blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

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

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) → QObject
property(self, 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, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
targetValueChanged
thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = - 1) → str
class schrodinger.maestro_utils.maestro_sync.TitleTarget(group_manager, parent=None)

Bases: schrodinger.models.mappers.TargetMixin, PyQt5.QtCore.QObject

Target for managing the title of an entry group via a group manager.

__init__(group_manager, parent=None)

Initialize self. See help(type(self)) for accurate signature.

targetGetValue()

See mappers.TargetMixin for full documentation.

Returns

the current group title

Return type

str

targetSetValue(value)

See mappers.TargetMixin for full documentation.

Parameters

value (str) – a new group title

auto_update_model = True
auto_update_target = True
blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

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

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) → QObject
property(self, 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, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
targetValueChanged
thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = - 1) → str