From ea26057b531851c445e28c3f141929258c1361d6 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Sat, 4 Nov 2023 11:57:47 +0100 Subject: [PATCH 1/2] abstract CWL test: recusively validate Fixes: #51 --- tests/test_export_abstract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_export_abstract.py b/tests/test_export_abstract.py index a1ebe67..a984c93 100644 --- a/tests/test_export_abstract.py +++ b/tests/test_export_abstract.py @@ -5,10 +5,10 @@ getdefault, LoadingContext, ) +from cwltool.load_tool import recursive_resolve_and_validate_document from cwltool.main import ( default_loader, fetch_document, - resolve_and_validate_document, tool_resolver, ) @@ -140,7 +140,7 @@ def _run_example(as_dict, out=None): ) loadingContext.resolver = getdefault(loadingContext.resolver, tool_resolver) loadingContext, workflowobj, uri = fetch_document(out, loadingContext) - loadingContext, uri = resolve_and_validate_document( + loadingContext, uri = recursive_resolve_and_validate_document( loadingContext, workflowobj, uri, From 33c7572c322779787b6d941603d0bfa6153c88b9 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Tue, 16 Apr 2024 18:42:07 +0200 Subject: [PATCH 2/2] partial fix for valid CWL abstract export --- dev-requirements.txt | 4 ++-- gxformat2/abstract.py | 8 ++++++-- tests/example_wfs.py | 6 ++++++ tests/test_export_abstract.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 3b1a54f..eac118f 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # Optional dependencies schema-salad[pycodegen] -# Needs to validate v1.2 -cwltool>=3.0.20200807132242 +# Needs to validate v1.2, recursive_resolve_and_validate_document +cwltool>=3.0.20201117141248 mypy diff --git a/gxformat2/abstract.py b/gxformat2/abstract.py index 847b9f8..3b34540 100644 --- a/gxformat2/abstract.py +++ b/gxformat2/abstract.py @@ -82,14 +82,18 @@ def _format2_step_to_abstract(format2_step, requirements): step_run = { "class": "Operation", "doc": format2_step.get("doc", ""), - "inputs": {}, # TODO - "outputs": {}, # TODO + "inputs": _format2_wfstep_inputs_to_abstract(format2_step), + "outputs": { out: "Any" for out in format2_step["out"] } } abstract_step["run"] = step_run abstract_step["in"] = _format2_in_to_abstract(format2_step.get("in", [])) abstract_step["out"] = _format2_out_to_abstract(format2_step) return abstract_step +def _format2_wfstep_inputs_to_abstract(format2_step): + if "in" in format2_step: + return { name: "Any" for name in format2_step["in"].keys() } + return {} def _format2_in_to_abstract(in_dict): """Convert Format2 'in' dict for step into CWL abstract 'in' dict.""" diff --git a/tests/example_wfs.py b/tests/example_wfs.py index cb641d5..23a8d46 100644 --- a/tests/example_wfs.py +++ b/tests/example_wfs.py @@ -18,6 +18,8 @@ doc: cat doc in: input1: the_input + out: + out_file1: {} """ WORKFLOW_WITH_REPEAT = """ @@ -100,6 +102,8 @@ mapping: - type: list_identifiers columns: [0, 1] + out: + output: {} random_lines: tool_id: random_lines1 state: @@ -109,6 +113,8 @@ seed_source: seed_source_selector: set_seed seed: asdf + out: + out_file1: {} """ RUNTIME_INPUTS = """ diff --git a/tests/test_export_abstract.py b/tests/test_export_abstract.py index a984c93..b56dce1 100644 --- a/tests/test_export_abstract.py +++ b/tests/test_export_abstract.py @@ -140,7 +140,7 @@ def _run_example(as_dict, out=None): ) loadingContext.resolver = getdefault(loadingContext.resolver, tool_resolver) loadingContext, workflowobj, uri = fetch_document(out, loadingContext) - loadingContext, uri = recursive_resolve_and_validate_document( + loadingContext, uri, process = recursive_resolve_and_validate_document( loadingContext, workflowobj, uri,