Created
April 26, 2018 18:40
-
-
Save mekhami/b7b60c1b0c308bf304f4f106ab6e5863 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@resource_op | |
def query_workflow_definitions(filters=None, deep_copy=False, params=None, | |
ignore_deleted=True, session=None, agent=None, return_dict=True): | |
filters = filters or {} | |
# Tags | |
q = session.query(Tag) | |
tags = q.all() | |
# Workflows | |
q = session.query(Workflow) | |
ws = q.all() | |
# Get the WorkflowDefinitions | |
q = session.query(WorkflowDefinition) | |
if ignore_deleted: | |
q = q.filter(WorkflowDefinition.archived == False) | |
q = q.options( | |
# lazyload('instances'), | |
joinedload(WorkflowDefinition.workflow_protocols) # joinedload faster | |
.joinedload(WorkflowProtocol.protocol) # joinedload faster | |
.subqueryload(Protocol.head.of_type(ProtocolDefinition)), | |
joinedload(WorkflowDefinition.step_lims_vars) # joinedload faster | |
.subqueryload(StepLimsVar.variable), | |
joinedload('workflow_sample_types') | |
.subqueryload('sample_type') | |
.subqueryload('head'), | |
) | |
# Load Workflows/Protocols | |
if not return_dict: | |
return q.all() | |
wf_dicts = [wf.as_dict(deep_copy, params) for wf in q.all()] | |
return wf_dicts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment