schrodinger.application.matsci.wfmanagement module¶
Module for saving, deleting and managing template workflow information
Copyright Schrodinger, LLC. All rights reserved.
- schrodinger.application.matsci.wfmanagement.case_insensitive_file_exists(directory, filename)¶
Check if
filename
exists indirectory
in case-insensitive manner- Parameters
directory (str) – Directory to check the file existence
filename (str) – Name of the file to be checked in case-insensitive manner
- Returns
True if file exists else False
- Return type
bool
- schrodinger.application.matsci.wfmanagement.read_workflow_metadata(metadata_file)¶
Read the workflow metadata contents from
metadata_file
- Parameters
metadata_file (str) – Path to the metadata json file
- Returns
A json dictionary of workflow name to metadata
- Return type
dict[dict]
- Raises
IOError, JSONDecodeError
- schrodinger.application.matsci.wfmanagement.update_workflow_metadata(metadata_file, workflow_metadata, orig_name=None)¶
Update the metadata.json file for the given
workflow_metadata
. If an existing entry needs to be renamed and updated, then pass its name inorig_name
.- Parameters
metadata_file (str) – Path to the metadata.json file
workflow_metadata (WorkflowMetadata) – An instance of
WorkflowMetadata
orig_name (str) – Name of the key in metadata.json file
- Raises
PermissionError, IOError, JSONDecodeError
- schrodinger.application.matsci.wfmanagement.delete_workflow_metadata(metadata_file, workflow_name)¶
Delete the workflow metadata from metadata_file for the given workflow_name
- Parameters
metadata_file (str) – Path to the metadata.json file
workflow_name (str) – Name of the key in metadata.json file
- Raises
PermissionError, IOError, JSONDecodeError
- schrodinger.application.matsci.wfmanagement.validate_workflow_name(name, reserved_names=None)¶
Validate the given workflow name. The
name
is checked inreserved_names
list in case-insensitive manner because this will be used as filename for the workflow and on Windows filenames are case-insensitive- Parameters
reserved_names (list(str)) – List of names not to accept
- Returns
Error string if
name
is invalid else empty string- Return type
str
- class schrodinger.application.matsci.wfmanagement.WorkflowMetadata(name='', description='', tags='', suite='', creator='')¶
Bases:
object
Class to hold the workflow metadata
- __init__(name='', description='', tags='', suite='', creator='')¶
- Parameters
name (str) – Workflow name
description (str) – Description of the workflow
tags (str) – Comma separated keywords that describes the workflow
suite (str) – Schrodinger suite version with which the workflow has been created
creator (str) – Workflow creator
- as_dict()¶
Return the
WorkflowMetadata
as a dict- Returns
The instance as a dict
- Return type
dict
- classmethod from_dict(data)¶
Return an instance of
WorkflowMetadata
from a dict- Parameters
data (dict) – Workflow metadata as a dictionary
- empty()¶
Check if the
WorkflowMetadata
is empty. AWorkflowMetadata
is considered empty if all of its values are empty- Returns
True if empty else False
- Return type
bool
- equals(data)¶
Check if the
data
is same as this instance- Parameters
data (WorkflowMetadata) – Workflow metadata instance to compare
- tostring()¶
Return the string represenation of the
WorkflowMetadata
object where all the data members are concatenated by space- Returns
String represenatation of this instance
- Rtye
str
- class schrodinger.application.matsci.wfmanagement.WorkflowMetadataFrame(layout=None, wkf_metadata=None, mode='view', user_update_function=None)¶
Bases:
schrodinger.ui.qt.widgetmixins.basicmixins.MessageBoxMixin
,schrodinger.ui.qt.swidgets.SFrame
GUI for the workflow metadata. This class can be created in 3 different modes, MODE_VIEW (read_only), MODE_CREATE (‘write_only’) and MODE_UPDATE (‘read/write’)
- NAME = 'Name:'¶
- DESCRIPTION = 'Description:'¶
- TAGS = 'Tags:'¶
- SUITE = 'Suite:'¶
- CREATOR = 'Creator:'¶
- MODE_VIEW = 'view'¶
- MODE_CREATE = 'create'¶
- MODE_UPDATE = 'update'¶
- __init__(layout=None, wkf_metadata=None, mode='view', user_update_function=None)¶
Create an instance of WorkflowMetadataFrame based on the
mode
. Ifwkf_metadata
is passed, then the frame is initialized with this data.- Parameters
wkf_metadata (WorkflowMetadata) – Instance of
WorkflowMetadata
layout (QLayout) – The layout to place this
WorkflowMetadataFrame
mode (MODE_VIEW, MODE_CREATE, MODE_UPDATE) – Mode in which to create the workflow metadata frame
user_update_function (func(WorkflowMetadata)) – A callback function to be called when a workflow is saved after editing (used in MODE_UPDATE)
- createTopFrame()¶
Create top frame for Update mode that contains the edit, save and close buttons
- createViewFrame()¶
Create the WorkflowMetadataFrame in view mode
- createEditableFrame()¶
Create the WorkflowMetadataFrame in editable mode
- setEditable(editable)¶
Set the Update mode’s view. This method is applicable only for Update mode.
- Parameters
editable (bool) – Whether the Update mode is editable or not
- setMetadata(wkf_metadata)¶
Update the metadata frame contents based on the
wkf_metadata
. If None is passed, then clear all the fields- Parameters
wkf_metadata (
WorkflowMetadata
) – Instance of WorkflowMetadata
- getName()¶
Return the name of the current workflow metadata
- Returns
Name of the current workflow metadata
- Return type
str
or None
- getMetadata()¶
Return the current workflow metadata instance
- Returns
Current workflow metadata instance
- Return type
- class schrodinger.application.matsci.wfmanagement.WorkflowNamerDialog(*args, reserved_names=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SDialog
A dialog that allows the user to provide a name and metadata for a new workflow
- __init__(*args, reserved_names=None, **kwargs)¶
Create a WorkflowNamerDialog instance
See parent class for documentation
- Parameters
reserved_names (list) – List of reserved workflow names
- layOut()¶
See parent class for documentation
- accept()¶
See parent class for documentation
- class schrodinger.application.matsci.wfmanagement.WorkflowFilterWidget(label=None, filterlabel='Filter:', filter='within', filterside='bottom', case=False, layout=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SFilteredListWidget
List widget that filter workflows based on its metadata
- filterList(filtervalue)¶
Filter the items in the list widget according to the contents of the LineEdit and our filter rules
- Parameters
filtervalue (str) – The current value to filter the ListWidget by
- class schrodinger.application.matsci.wfmanagement.WorkflowFinder(user_location='', std_location='', file_suffix='', reserved_names=None, **kwargs)¶
Bases:
schrodinger.ui.qt.widgetmixins.basicmixins.MessageBoxMixin
,schrodinger.ui.qt.swidgets.SFrame
Class that lists workflows under specified
user_location
andstd_location
. On selecting a workflow, it displays its metadata if available- NO_WORKFLOWS = 'No workflows found'¶
- workflow_selection_changed¶
A
pyqtSignal
emitted by instances of the class.
- __init__(user_location='', std_location='', file_suffix='', reserved_names=None, **kwargs)¶
Create a WorkflowFinder instance
- Parameters
user_location (str) – Directory that contains user created workflows
std_location – Directory that contains std workflows
file_suffix (str) – Workflow file suffix
reserved_names (list(str)) – List of reserved workflow names
- workflowMetadataMode()¶
Mode in which the
WorkflowMetadataFrame
will be created.- Returns
WorkflowMetadataFrame creation mode
- Return type
str
- filterWorkflows(text, filtertext, case_sensitive)¶
Custom filter function to filter the listwidget entries. Checks if the filtertext is available in whole workflow metadata apart from the workflow name
- Parameters
text (str) – Text to be filtered
filtertext (str) – Text to be searched for
case_sensitive (bool) – Enable case sensitive search if True
- Returns
True if filtertext is found else False
- Return type
bool
- selectedWorkflowName()¶
Get the user-facing name for the selected workflow
- Return type
str or None
- Returns
The name of the selected workflow, or None if there is no selection
- selectedWorkflowPath()¶
Get the path to the selected workflow
- Return type
str or None
- Returns
The path to the selected workflow, or None if there is no selection
- selectedWorkflowBasename()¶
Return the basename of selected workflow file path
- Return type
str or None
- Returns
Basename of selected workflow filepath, or None if there is no selection
- userWorkflow(workflow_path)¶
Check if the
workflow_path
is an user created workflow. Any workflow underself.user_location
is treated as a user workflow- Returns
True if user workflow else False
- Return type
bool
- loadNewWorkflow()¶
Callback function when a workflow is selected in the list. Update the WorkflowMetadataFrame for the selected workflow
- getUserText(workflow_filepath)¶
Return the user friendly name for the workflow based on the
workflow_filepath
- Returns
User friendly name from workflow filepath
- Return type
str
- getWorkflowPaths()¶
Get the list of workflow paths to be displyed
- Returns
List of workflow paths to be displayed
- Return type
list(str)
- reset()¶
Reset the widgets
- validate()¶
Validate that a workflow is selected
- Return type
bool or (bool, str)
- Returns
The bool is True if everything is OK, False if not. str is given if a dialog should pop up to show the given message. If bool is True, str will post as Question dialog.
- class schrodinger.application.matsci.wfmanagement.WorkflowManagerMixin(*args, **kwargs)¶
Bases:
object
A mixin to be used with
WorkflowFinder
that allows managing the workflows, like renaming the workflow, deleting the workflow and editing its metadata- __init__(*args, **kwargs)¶
Create a WorkflowManagerMixin instance
- workflowMetadataMode()¶
Mode in which the
WorkflowMetadataFrame
will be created.- Returns
WorkflowMetadataFrame creation mode
- Return type
str
- onWorkflowSelected()¶
Slot called when
workflow_selection_changed
signal is emitted
- updateMetadata(metadata)¶
Callback function called on saving the metadata. Rename the workflow file (if the name is modified) and update the workflow metadata file
- Parameters
metadata (WorkflowMetadata) – Instance of
WorkflowMetadata
- Returns
True if success else False
- Return type
bool
- deleteWorkflow()¶
Delete the selected workflow
- class schrodinger.application.matsci.wfmanagement.WorkflowManager(*args, **kwargs)¶
Bases:
schrodinger.application.matsci.wfmanagement.WorkflowManagerMixin
,schrodinger.application.matsci.wfmanagement.WorkflowFinder
Class that lists workflows and allows renaming workflows, deleting workflows and editing its metadata
- class schrodinger.application.matsci.wfmanagement.BaseWorkflowFinderDialog(*args, user_location='', std_location='', file_suffix='', reserved_names=None, **kwargs)¶
Bases:
schrodinger.ui.qt.swidgets.SDialog
A Base dialog that lists existing workflows. Should not be used directly
All subclasses _must_ implement
createWidget
method that creates and returns an instance ofWorkflowFinder
. This widget will be set as the main widget for the dialog- __init__(*args, user_location='', std_location='', file_suffix='', reserved_names=None, **kwargs)¶
- Parameters
user_location (str) – Directory that contains user created workflows
std_location – Directory that contains std workflows
file_suffix (str) – Workflow file suffix
reserved_names (list(str)) – List of reserved workflow names
- resizeDialog()¶
Subclasses can resize the dialog accordingly
- layOut()¶
See parent class for documentation
- createWidget(user_location='', std_location='', file_suffix='', reserved_names=None)¶
Create and return an instance of
WorkflowFinder
widget to be added to the dialog. To be implemented by subclasses.- Parameters
user_location (str) – Directory that contains user created workflows
std_location – Directory that contains std workflows
file_suffix (str) – Workflow file suffix
reserved_names (list(str)) – List of reserved workflow names
- Returns
WorkflowFinder instance to be added to the dialog
- Return type
- accept()¶
See parent class for documentation
- class schrodinger.application.matsci.wfmanagement.WorkflowFinderDialog(*args, user_location='', std_location='', file_suffix='', reserved_names=None, **kwargs)¶
Bases:
schrodinger.application.matsci.wfmanagement.BaseWorkflowFinderDialog
A dialog that allows the user to pick an existing workflow
- createWidget(user_location='', std_location='', file_suffix='', reserved_names=None)¶
See parent class for documentation
- class schrodinger.application.matsci.wfmanagement.WorkflowManagerDialog(*args, **kwargs)¶
Bases:
schrodinger.application.matsci.wfmanagement.BaseWorkflowFinderDialog
A dialog that allows the user to manage the workflows, like edit the workflow metadata, rename and delete the workflow.
- __init__(*args, **kwargs)¶
Initialize dialog with only Close button
- createWidget(user_location='', std_location='', file_suffix='', reserved_names=None)¶
See parent class for documentation