Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/commands/cmd_run.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 """Module describing the planemo ``cwl_run`` command.""" | |
| 2 from __future__ import print_function | |
| 3 | |
| 4 import json | |
| 5 | |
| 6 import click | |
| 7 from galaxy.util import unicodify | |
| 8 | |
| 9 from planemo import options | |
| 10 from planemo.cli import command_function | |
| 11 from planemo.engine import engine_context | |
| 12 from planemo.io import warn | |
| 13 from planemo.tools import uri_to_path | |
| 14 | |
| 15 | |
| 16 @click.command('run') | |
| 17 @options.required_tool_arg(allow_uris=True) | |
| 18 @options.required_job_arg() | |
| 19 @options.galaxy_run_options() | |
| 20 @options.galaxy_config_options() | |
| 21 @options.enable_cwl_option() | |
| 22 @options.galaxy_cwl_root_option() | |
| 23 @options.run_output_directory_option() | |
| 24 @options.run_output_json_option() | |
| 25 @options.engine_options() | |
| 26 @command_function | |
| 27 def cli(ctx, uri, job_path, **kwds): | |
| 28 """Planemo command for running tools and jobs. | |
| 29 | |
| 30 \b | |
| 31 % planemo run cat1-tool.cwl cat-job.json | |
| 32 """ | |
| 33 path = uri_to_path(ctx, uri) | |
| 34 # TODO: convert UI to runnable and do a better test of cwl. | |
| 35 is_cwl = path.endswith(".cwl") | |
| 36 kwds["cwl"] = is_cwl | |
| 37 if kwds.get("engine", None) is None: | |
| 38 kwds["engine"] = "galaxy" if not is_cwl else "cwltool" | |
| 39 | |
| 40 with engine_context(ctx, **kwds) as engine: | |
| 41 run_result = engine.run(path, job_path) | |
| 42 | |
| 43 if not run_result.was_successful: | |
| 44 warn("Run failed [%s]" % unicodify(run_result)) | |
| 45 ctx.exit(1) | |
| 46 | |
| 47 outputs_dict = run_result.outputs_dict | |
| 48 print(outputs_dict) | |
| 49 output_json = kwds.get("output_json", None) | |
| 50 if output_json: | |
| 51 with open(output_json, "w") as f: | |
| 52 json.dump(outputs_dict, f) | |
| 53 | |
| 54 return 0 |
