diff --git a/cwltool/main.py b/cwltool/main.py index 23c12d5955..24596306ed 100755 --- a/cwltool/main.py +++ b/cwltool/main.py @@ -1113,12 +1113,6 @@ def main( loadingContext, workflowobj, uri = fetch_document(uri, loadingContext) - if args.print_deps and loadingContext.loader: - printdeps( - workflowobj, loadingContext.loader, stdout, args.relative_deps, uri - ) - return 0 - loadingContext, uri = resolve_and_validate_document( loadingContext, workflowobj, @@ -1127,6 +1121,12 @@ def main( skip_schemas=args.skip_schemas, ) + if args.print_deps and loadingContext.loader: + printdeps( + workflowobj, loadingContext.loader, stdout, args.relative_deps, uri + ) + return 0 + if loadingContext.loader is None: raise Exception("Impossible code path.") processobj, metadata = loadingContext.loader.resolve_ref(uri) diff --git a/tests/test_examples.py b/tests/test_examples.py index c8e4c6fcca..da8d5f110e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -586,6 +586,28 @@ def test_scandeps_defaults_with_secondaryfiles() -> None: ].endswith(os.path.join("tests", "wf", "indir1")) +def test_issue_1765_print_deps_with_workflows_having_namespace_location_steps() -> None: + """Test for issue 1765. + + An external workflow step passed the validation, but failed to print-deps.""" + stream = StringIO() + + main( + [ + "--print-deps", + "--relative-deps=primary", + "--debug", + get_data( + "tests/wf/print_deps_with_workflows_having_namespace_location_steps.cwl" + ), + ], + stdout=stream, + ) + assert json.loads(stream.getvalue())["secondaryFiles"][0]["secondaryFiles"][0][ + "location" + ].endswith("EDAM_1.18.owl") + + def test_dedupe() -> None: not_deduped = [ {"class": "File", "location": "file:///example/a"}, diff --git a/tests/wf/print_deps_with_workflows_having_namespace_location_steps.cwl b/tests/wf/print_deps_with_workflows_having_namespace_location_steps.cwl new file mode 100644 index 0000000000..12f67fece3 --- /dev/null +++ b/tests/wf/print_deps_with_workflows_having_namespace_location_steps.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +# From: +# - https://github.com/common-workflow-language/cwltool/issues/1765 +# - https://github.com/pvanheus/lukasa/blob/99e827e0125cf07621253ae081199298adf7227b/protein_evidence_mapping.cwl +cwlVersion: v1.2 +class: Workflow + +inputs: + contigs_fasta: + label: "Genomic contigs (FASTA)" + type: File + format: edam:format_1929 +outputs: + out: + type: File + outputSource: + samtools_index_contigs/sequences_with_index + +steps: + samtools_index_contigs: + # This step is from an external file. print_deps failed here, with a validation + # error message, even though --validate passed. + run: bio-cwl-tools:samtools/samtools_faidx.cwl + in: + sequences: contigs_fasta + out: + - sequences_with_index +$namespaces: + edam: http://edamontology.org/ + bio-cwl-tools: https://raw.githubusercontent.com/common-workflow-library/bio-cwl-tools/release/ +$schemas: + - http://edamontology.org/EDAM_1.18.owl