Skip to content

Commit

Permalink
Revert "Revert "Partial support for subworkflows (#24)""
Browse files Browse the repository at this point in the history
This reverts commit 554d585.
  • Loading branch information
pinin4fjords committed Jul 26, 2021
1 parent 237e58b commit 63b3590
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 6 additions & 0 deletions generate_params_from_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def main():
if str(value['label']) != 'None':
step_id = key
step_name = value['label']
# check for nested workflows
# don't need to extract anything as all parameters in nested wfs
# are set explicitly from the outer workflow
# TODO in the future, deal with parameters for steps of inner workflows to be able to set them.
if show_wf['steps'][step_id]['type'] == 'subworkflow':
continue
content = show_wf['steps'][step_id]['tool_inputs']
if 'parameter_type' in content:
# treat simple input parameters differently
Expand Down
8 changes: 3 additions & 5 deletions run_galaxy_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""

import argparse
import os.path
from os import path, remove
from sys import exit
from bioblend.galaxy import GalaxyInstance
from bioblend import ConnectionError
Expand Down Expand Up @@ -194,8 +194,8 @@ def main():

# Produce tool versions file
produce_versions_file(gi=gi, workflow_from_json=wf_from_json,
path="{}/software_versions_galaxy.txt".format(args.output_dir))

table_path="{}/software_versions_galaxy.txt".format(args.output_dir))
# wait for a little while and check if the status is ok
logging.info("Waiting for results to be available...")
logging.info("...in the mean time, you can check {}/histories/view?id={} for progress."
Expand Down Expand Up @@ -302,5 +302,3 @@ def main():
if __name__ == '__main__':
main()



22 changes: 16 additions & 6 deletions wfexecutor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,32 @@ def process_allowed_errors(allowed_errors_dict, wf_from_json):

return allowed_errors_state

def produce_versions_file(gi, workflow_from_json, path):
def produce_versions_file(gi, workflow_from_json, table_path, tools_dict=[]):
"""
Produces a tool versions file for the workflow run.
:param gi:
:param workflow_from_json:
:param path: path where to save the versions file
:param table_path: path where to save the versions file
:param tools_dict: list of tools used in the workflow
:return:
"""
# remove file if exists already; but not in recursive case
if os.path.exists(table_path) and not tools_dict:
os.remove(table_path)

tools_dict = []

with open(file=path, mode="w") as f:
f.write("\t".join(["Analysis", "Software", "Version", "Citation"])+"\n")
with open(file=table_path, mode="a") as f:
# write header only if file is empty
if os.stat(table_path).st_size == 0:
f.write("\t".join(["Analysis", "Software", "Version", "Citation"])+"\n")

for key, step in sorted(workflow_from_json['steps'].items(), reverse=True):
# parse sub-workflows recursively
if "subworkflow" in step.keys():
subworkflow = step['subworkflow']
produce_versions_file(gi, subworkflow, table_path, tools_dict)
# subworkflows don't have meaningful tool ids
continue
# Input steps won't have tool ids, and we only need each tool once.
if step['tool_id'] is not None and step['tool_id'] not in tools_dict:
tool = gi.tools.show_tool(step['tool_id'])
Expand Down

0 comments on commit 63b3590

Please sign in to comment.