Ejemplo n.º 1
0
 def test(self, runnables):
     """Test runnable artifacts (workflow or tool)."""
     self._check_can_run_all(runnables)
     test_cases = [t for tl in map(cases, runnables) for t in tl]
     test_results = self._collect_test_results(test_cases)
     tests = []
     for (test_case, run_response) in test_results:
         test_case_data = test_case.structured_test_data(run_response)
         tests.append(test_case_data)
     test_data = {
         'version': '0.1',
         'tests': tests,
     }
     structured_results = StructuredData(data=test_data)
     structured_results.calculate_summary_data()
     return structured_results
Ejemplo n.º 2
0
 def test(self, runnables):
     """Test runnable artifacts (workflow or tool)."""
     self._check_can_run_all(runnables)
     test_cases = [t for tl in map(cases, runnables) for t in tl]
     test_results = self._collect_test_results(test_cases)
     tests = []
     for (test_case, run_response) in test_results:
         test_case_data = test_case.structured_test_data(run_response)
         tests.append(test_case_data)
     test_data = {
         'version': '0.1',
         'tests': tests,
     }
     structured_results = StructuredData(data=test_data)
     structured_results.calculate_summary_data()
     return structured_results
Ejemplo n.º 3
0
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)