def _cli(ctx, paths, glx, user_key, **kwds) -> Dict: """ Run specified tool's tests within Galaxy. Returns a dict of the status and history_name of the finished workflow. See https://github.com/galaxyproject/planemo/blob/master/planemo/commands/cmd_test.py """ kwds["engine"] = "external_galaxy" kwds["shed_install"] = False kwds["galaxy_url"] = glx.url kwds["galaxy_admin_key"] = glx.user_key kwds["history_name"] = "galaxy_benchmarker-" + str(time.time_ns()) + str( random.randrange(0, 99999)) if user_key is not None: kwds["galaxy_user_key"] = user_key runnables = for_paths(paths) try: with engine_context(ctx, **kwds) as engine: test_data = engine.test(runnables) exit_code = handle_reports_and_summary(ctx, test_data.structured_data, kwds=kwds) status = "success" if exit_code == 0 else "error" except Exception as e: log.error("There was an error: {e}".format(e=e)) status = "error" return {"status": status, "history_name": kwds["history_name"]}
def cli(ctx, paths, **kwds): """Run specified tool's tests within Galaxy. All referenced tools (by default all the tools in the current working directory) will be tested and the results quickly summarized. To run these tests planemo needs a Galaxy instance to utilize, planemo will search parent directories to see if any is a Galaxy instance - but one can pick the Galaxy instance to use with the --galaxy_root option or force planemo to download a disposable instance with the ``--install_galaxy`` flag. In additon to to quick summary printed to the console - various detailed output summaries can be configured. ``tool_test_output.html`` (settable via ``--test_output``) will contain a human consumable HTML report describing the test run. A JSON file (settable via ``--test_output_json`` and defaulting to ``tool_test_output.json``) will also be created. These files can can be disabled by passing in empty arguments or globally by setting the values ``default_test_output`` and/or ``default_test_output_json`` in ``~/.planemo.yml`` to ``null``. For continuous integration testing a xUnit-style report can be confiured using the ``--test_output_xunit``. planemo uses temporarily generated config files and environment variables to attempt to shield this execution of Galaxy from manually launched runs against that same Galaxy root - but this may not be bullet proof yet so please careful and do not try this against production Galaxy instances. """ runnables = for_paths(paths) is_cwl = all([ r.type in [RunnableType.cwl_tool, RunnableType.cwl_workflow] for r in runnables ]) if kwds.get("engine", None) is None: kwds["engine"] = "galaxy" if not is_cwl else "cwltool" engine_type = kwds["engine"] enable_test_engines = any([ r.type not in [ RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory ] for r in runnables ]) enable_test_engines = enable_test_engines or engine_type != "galaxy" if enable_test_engines: ctx.vlog("Using test engine type %s" % engine_type) with engine_context(ctx, **kwds) as engine: test_data = engine.test(runnables) return_value = handle_reports_and_summary( ctx, test_data.structured_data, kwds=kwds) else: ctx.vlog( "Running traditional Galaxy tool tests using run_tests.sh in Galaxy root %s" % engine_type) kwds["for_tests"] = True with galaxy_config(ctx, runnables, **kwds) as config: return_value = run_in_config(ctx, config, **kwds) ctx.exit(return_value)
def cli(ctx, paths, **kwds): """Run specified tool's tests within Galaxy. All referenced tools (by default all the tools in the current working directory) will be tested and the results quickly summarized. To run these tests planemo needs a Galaxy instance to utilize, planemo will search parent directories to see if any is a Galaxy instance - but one can pick the Galaxy instance to use with the --galaxy_root option or force planemo to download a disposable instance with the ``--install_galaxy`` flag. In additon to to quick summary printed to the console - various detailed output summaries can be configured. ``tool_test_output.html`` (settable via ``--test_output``) will contain a human consumable HTML report describing the test run. A JSON file (settable via ``--test_output_json`` and defaulting to ``tool_test_output.json``) will also be created. These files can can be disabled by passing in empty arguments or globally by setting the values ``default_test_output`` and/or ``default_test_output_json`` in ``~/.planemo.yml`` to ``null``. For continuous integration testing a xUnit-style report can be confiured using the ``--test_output_xunit``. planemo uses temporarily generated config files and environment variables to attempt to shield this execution of Galaxy from manually launched runs against that same Galaxy root - but this may not be bullet proof yet so please careful and do not try this against production Galaxy instances. """ runnables = for_paths(paths) is_cwl = all([r.type in [RunnableType.cwl_tool, RunnableType.cwl_workflow] for r in runnables]) if kwds.get("engine", None) is None: kwds["engine"] = "galaxy" if not is_cwl else "cwltool" engine_type = kwds["engine"] enable_test_engines = any([r.type not in [RunnableType.galaxy_tool, RunnableType.directory] for r in runnables]) enable_test_engines = enable_test_engines or engine_type != "galaxy" if enable_test_engines: ctx.vlog("Using test engine type %s" % engine_type) with engine_context(ctx, **kwds) as engine: test_data = engine.test(runnables) return_value = handle_reports_and_summary(ctx, test_data.structured_data, kwds=kwds) else: ctx.vlog("Running traditional Galaxy tool tests using run_tests.sh in Galaxy root %s" % engine_type) kwds["for_tests"] = True with galaxy_config(ctx, runnables, **kwds) as config: return_value = run_in_config(ctx, config, **kwds) ctx.exit(return_value)
def test_runnables(ctx, runnables, original_paths=None, **kwds): """Return exit code indicating test or failure.""" engine_type = kwds["engine"] test_engine_testable = {RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory} enable_test_engines = any(r.type not in test_engine_testable for r in runnables) enable_test_engines = enable_test_engines or engine_type != "galaxy" if enable_test_engines: ctx.vlog("Using test engine type %s" % engine_type) with engine_context(ctx, **kwds) as engine: test_data = engine.test(runnables) ctx.vlog("engine.test returning [%s]" % test_data) return_value = handle_reports_and_summary(ctx, test_data.structured_data, kwds=kwds) else: ctx.vlog("Running traditional Galaxy tool tests using run_tests.sh in Galaxy root %s" % engine_type) kwds["for_tests"] = True if kwds.get('update_test_data'): non_copied_runnables = for_paths(original_paths) kwds['test_data_target_dir'] = _find_test_data(non_copied_runnables, **kwds) with galaxy_config(ctx, runnables, **kwds) as config: return_value = run_in_config(ctx, config, **kwds) return return_value
def cli(ctx, runnable_identifier, job_path, **kwds): """Planemo command for running tools and jobs. \b % planemo run cat1-tool.cwl cat-job.json """ runnable = for_runnable_identifier(ctx, runnable_identifier, kwds) is_cwl = runnable.type.is_cwl_artifact kwds["cwl"] = is_cwl kwds["execution_type"] = "Run" if kwds.get("engine", None) is None: if is_cwl: kwds["engine"] = "cwltool" elif kwds.get('galaxy_url', None): kwds["engine"] = "external_galaxy" else: kwds["engine"] = "galaxy" with engine_context(ctx, **kwds) as engine: run_result = engine.run(runnable, job_path) if not run_result.was_successful: warn("Run failed [%s]" % unicodify(run_result)) elif kwds.get('no_wait'): info('Run successfully executed - exiting without waiting for results.') else: output_json = kwds.get("output_json", None) outputs_dict = run_result.outputs_dict if output_json: with open(output_json, "w") as f: json.dump(outputs_dict, f) info('Run completed successfully.') report_data = StructuredData(data={'tests': [run_result.structured_data()], 'version': '0.1'}) report_data.calculate_summary_data() return_value = handle_reports_and_summary(ctx, report_data.structured_data, kwds=kwds) ctx.exit(return_value)