Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions ephemeris/workflow_install.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
#!/usr/bin/env python
import argparse
import json
import os

from bioblend import galaxy


def import_workflow(gi, path):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstring.

with open(path, 'r') as wf_file:
import_uuid = json.load(wf_file).get('uuid')
existing_uuids = [d.get('latest_workflow_uuid') for d in gi.workflows.get_workflows()]
if import_uuid not in existing_uuids:
gi.workflows.import_workflow_from_local_path(path)


def main():
"""
This script uses bioblend to import .ga workflow files into a running instance of Galaxy
"""
parser = argparse.ArgumentParser()
parser.add_argument("-w", "--workflow_path", help='Path to workflow file')
parser.add_argument("-w", "--workflow_path",
help='Path to a workflow file or a directory with multiple workflow files ending with ".ga"')
parser.add_argument("-g", "--galaxy",
dest="galaxy_url",
help="Target Galaxy instance URL/IP address (required "
"if not defined in the tools list file)",)
parser.add_argument("-a", "--apikey",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not leave both options?

dest="api_key",
help="Galaxy admin user API key (required if not "
"defined in the tools list file)",)
help="Target Galaxy instance URL/IP address.")
parser.add_argument("-u", "--user",
help="Galaxy user name")
parser.add_argument("-p", "--password",
help="Password for the Galaxy user")
args = parser.parse_args()

gi = galaxy.GalaxyInstance(url=args.galaxy_url, key=args.api_key)
gi = galaxy.GalaxyInstance(url=args.galaxy, email=args.user, password=args.password)

with open(args.workflow_path, 'r') as wf_file:
import_uuid = json.load(wf_file).get('uuid')
existing_uuids = [d.get('latest_workflow_uuid') for d in gi.workflows.get_workflows()]
if import_uuid not in existing_uuids:
gi.workflows.import_workflow_from_local_path(args.workflow_path)
if os.path.isdir(args.workflow_path):
for file_path in os.listdir(args.workflow_path):
if file_path.endswith('.ga'):
import_workflow(gi, os.path.join(args.workflow_path, file_path))
else:
import_workflow(gi, args.workflow_path)


if __name__ == '__main__':
Expand Down