-
Notifications
You must be signed in to change notification settings - Fork 42
Support directories full of workflows #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e9bf7c
Support directories full of workflows
bgruening 788323f
pep8 fixes
bgruening 3891cec
Add missing import
bgruening 3b83f01
Using user and password instead of master API key
bgruening 2b0a302
Add docstring and API option
bgruening dfba304
fix pep8
bgruening File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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): | ||
| 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", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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__': | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstring.