schrodinger.application.matsci.restart_gui module

Reusable Qt widgets for displaying restartable JobDJ workflows.

This module contains presentation and interaction code only. Checkpoint serialization and workflow execution belong in schrodinger.application.matsci.restart.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.restart_gui.RestartNodeViewer(*args, **kwargs)

Bases: NodeViewer

NodeGraph viewer whose scrollbars retain the full graph bounds.

__init__(*args, **kwargs)
Args:

parent: undo_stack (QtWidgets.QUndoStack): undo stack from the parent

graph controller.

setContentRect(content_rect)

Set the complete scrollable graph bounds.

setViewRect(view_rect)

Set the currently visible graph bounds.

viewRect()

Return the currently visible graph bounds.

scrollContentsBy(dx, dy)

Keep NodeGraph’s visible bounds synchronized with scrollbars.

schrodinger.application.matsci.restart_gui.get_job_graph(restart_state)

Build a directed visualization graph from saved job information.

The returned graph is presentation data only and must not be used to determine restart execution state.

Parameters:

restart_state (dict) – Loaded restart checkpoint state.

Return type:

networkx.DiGraph

Returns:

Job names and immediate dependency edges.

schrodinger.application.matsci.restart_gui.get_graph_dimensions(job_graph)

Return the structural width and height of a directed acyclic graph.

Width is the largest topological generation. Height is the number of generations.

Parameters:

job_graph (networkx.DiGraph) – Restart visualization graph.

Return type:

tuple(int, int)

Returns:

Graph width and height.

schrodinger.application.matsci.restart_gui.get_job_restart_state(restart_state, jobname)

Return a job’s saved completion state.

Parameters:
  • restart_state (dict) – Loaded restart checkpoint state.

  • jobname (str) – Stable JobDJ job name.

Return type:

str or None

Returns:

Completed, skipped, or incomplete state.

class schrodinger.application.matsci.restart_gui.RestartNodeItem(*args, **kwargs)

Bases: NodeItem

NodeGraphQt item with fixed geometry for restart graph nodes.

NODE_WIDTH = 140
NODE_HEIGHT = 70
setNodeSize()

Set the common dimensions used by every restart graph node.

__init__(*args, **kwargs)

Create a fixed-size restart node item.

Parameters:
  • args (tuple) – Positional arguments forwarded to NodeItem.

  • kwargs (dict) – Keyword arguments forwarded to NodeItem.

draw_node()

Draw the node and restore any workflow-specific port positions.

setPipeStyle()

Keep connected pipes at the restart-graph style.

activate_pipes()

Keep pipe styling unchanged when a pipe is activated.

highlight_pipes()

Keep pipe styling unchanged when a node is selected.

reset_pipes()

Keep pipe styling unchanged when a node is deselected.

class schrodinger.application.matsci.restart_gui.RestartGraphNode(jobname, input_ports=None, output_ports=None, node_item=<class 'schrodinger.application.matsci.restart_gui.RestartNodeItem'>)

Bases: BaseNode

NodeGraphQt node representing one restart job.

NODE_NAME

Initial base node name.

Important

re-implement this attribute to provide a base node name.

1from NodeGraphQt import NodeObject
2
3class ExampleNode(NodeObject):
4
5    # initial default node name.
6    NODE_NAME = 'Example Node'
7
8    def __init__(self):
9        ...
Returns:

node name

Return type:

str

COLOR = (211, 211, 211)
__init__(jobname, input_ports=None, output_ports=None, node_item=<class 'schrodinger.application.matsci.restart_gui.RestartNodeItem'>)

Create a restart graph node with the requested ports and view item.

Parameters:
  • jobname (str) – Stable JobDJ job name.

  • input_ports (tuple(str) or None) – Names of input ports to create.

  • output_ports (tuple(str) or None) – Names of output ports to create.

  • node_item (type) – QGraphics item class used to draw the node.

class schrodinger.application.matsci.restart_gui.RestartGraphFrame(layout=None, layout_type='vertical')

Bases: SFrame

NodeGraphQt view of the generic restart job graph.

GRAPH_MINIMUM_WIDTH = 550
GRAPH_MINIMUM_HEIGHT = 300
__init__(layout=None, layout_type='vertical')

Create a restart graph frame.

Parameters:
  • layout (QtWidgets.QLayout or None) – Layout that owns this frame.

  • layout_type (str) – Graph orientation.

clearNodeGraph()

Clear displayed NodeGraphQt nodes after unlocking their ports.

clearGraph()

Clear structural, displayed, and selected graph data.

getNodeProperties(node)

Return properties displayed for a graph node.

Parameters:

node (str) – Graph node identifier.

Return type:

dict

Returns:

Saved job information.

getNodeTooltip(node)

Return the property information displayed when hovering over a node.

Parameters:

node (str) – Graph node identifier.

Return type:

str

Returns:

Formatted node properties.

setNodeTooltip(node)

Apply the job-property tooltip to a rendered graph node.

Parameters:

node (str) – Graph node identifier.

getNodeLabel(node)

Return the label drawn for a graph node.

Parameters:

node (str) – Graph node identifier.

Return type:

str

layoutGraph()

Center topological generations and orient the longer dimension horizontally.

Return type:

dict

Returns:

Graph positions keyed by node identifier.

updateGraphNode(node)

Apply the current label and tooltip to a displayed node.

Parameters:

node (str) – Graph node identifier.

updateNodeStatus(node)

Set the status text and color from checkpoint and job status.

Parameters:

node (str) – Graph node identifier.

positionNodeStatusText(node)

Center the status text at the bottom of the node body.

Parameters:

node (str) – Graph node identifier.

addGraphNode(node)

Add one positioned job node to the NodeGraphQt view.

Parameters:

node (str) – Graph node identifier.

createGraphNode(node)

Return the displayed NodeGraphQt node for a job.

getGraphPorts(parent, dependent)

Return the output and input ports for a graph edge.

static lockGraphNode(graph_node)

Prevent graph editing while retaining node selection.

Parameters:

graph_node (RestartGraphNode) – Displayed node to lock.

fitInitialGraph()

Fit no more than five node rows and columns in the initial view.

drawGraph(preserve_view=False)

Rebuild the NodeGraphQt view from the current structural graph.

Parameters:

preserve_view (bool) – Whether to retain zoom and viewport center.

graphSelectionChanged(selected_nodes, _deselected_nodes)

Display properties for the most recently selected graph node.

Parameters:
selectNode(node)

Select a graph node and display its properties.

Parameters:

node (str) – Graph node identifier.

nodeSelectionChanged(node)

Respond to a selected graph node.

Subclasses may override this hook to display node-specific actions.

Parameters:

node (str or None) – Selected graph node identifier.

setJobGraph(restart_state)

Build and display the graph saved in restart job information.

Parameters:

restart_state (dict) – Loaded restart checkpoint state.

class schrodinger.application.matsci.restart_gui.RestartFrame(panel, layout=None)

Bases: RestartGraphFrame

Load, display, and validate a restart checkpoint.

__init__(panel, layout=None)
Parameters:
  • panel – Parent application panel.

  • layout (QtWidgets.QLayout) – Layout that owns this frame.

isLoaded()
Return type:

bool

Returns:

Whether a checkpoint is loaded.

clearLoadedData()

Clear loaded checkpoint data and the graph.

showLoadError(message, checkpoint_file)

Clear partial state and report a checkpoint loading error.

Parameters:
  • message (str) – Error message.

  • checkpoint_file (str) – Checkpoint that could not be loaded.

loadCheckpoint(checkpoint_file=None)

Load and display a restart checkpoint.

Parameters:

checkpoint_file (str) – Optional path overriding the selector.

validateJobGraph()

Check the saved outputs of every completed job in the graph.

Each job is made the sole frontier in a temporary restart state so RestartableDriver performs its standard file and directory expansion. Saved paths are resolved by basename beside the loaded checkpoint.

Return type:

bool

Returns:

Whether every completed job has its required outputs.

validate()

Validate the loaded restart checkpoint.

Missing job artifacts are presentation state from validateJobGraph and do not block launch. The driver owns restart file handling.

Return type:

bool or tuple(bool, str)

Returns:

Validation result.

copyRestartFiles(destination='.')

Copy the files needed to write a portable restart job.

Missing job artifacts are omitted so their jobs can be rerun. The original workflow inputs and checkpoint itself must still exist.

Parameters:

destination (str) – Directory receiving the restart files.

getRestartFilename()

Return the basename used for the copied restart checkpoint.

Return type:

str

Returns:

Restart checkpoint filename.

getFlags(jobname)

Return the checkpoint restart flags.

Parameters:

jobname (str) – Current launch job name.

Return type:

list(str)

Returns:

Driver flags.