diff --git a/MANIFEST.in b/MANIFEST.in index 5e22a597..4b76c329 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -21,6 +21,7 @@ include testdata/workflows/*.cwl include testdata/workflows/*.yaml include testdata/types/*.yml include testdata/checker_wf/*.cwl +include testdata/extensions/*.cwl include cwl_utils/py.typed include docs/conf.py docs/Makefile docs/_static/favicon.ico docs/requirements.txt include docs/*.rst diff --git a/pyproject.toml b/pyproject.toml index 1c4ba78a..4519fb4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ packages = [ "cwl_utils.tests", "cwl_utils.testdata", "cwl_utils.testdata.checker_wf", + "cwl_utils.testdata.extensions", "cwl_utils.testdata.types", "cwl_utils.testdata.workflows", ] @@ -77,6 +78,7 @@ include-package-data = true "cwl_utils.tests" = "tests" "cwl_utils.testdata" = "testdata" "cwl_utils.testdata.checker_wf" = "testdata/checker_wf" +"cwl_utils.testdata.extensions" = "testdata/extensions" "cwl_utils.testdata.types" = "testdata/types" "cwl_utils.testdata.workflows" = "testdata/workflows" diff --git a/requirements.txt b/requirements.txt index 3eac45ed..d24b7145 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ cwl-upgrader >= 1.2.3 packaging rdflib requests -schema-salad @ git+https://github.com/common-workflow-language/schema_salad.git +schema-salad >= 8.8.20241206093842, < 9 ruamel.yaml >= 0.17.6, < 0.19 diff --git a/testdata/extensions/all-output-loop_v1_2.cwl b/testdata/extensions/all-output-loop_v1_2.cwl new file mode 100644 index 00000000..096be519 --- /dev/null +++ b/testdata/extensions/all-output-loop_v1_2.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.2 +class: Workflow +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + InlineJavascriptRequirement: {} +inputs: + i1: int +outputs: + o1: + type: int[] + outputSource: subworkflow/o1 +steps: + subworkflow: + run: + class: ExpressionTool + inputs: + i1: int + outputs: + o1: int + expression: > + ${return {'o1': inputs.i1 + 1};} + in: + i1: i1 + out: [o1] + requirements: + cwltool:Loop: + loopWhen: $(inputs.i1 < 10) + loop: + i1: o1 + outputMethod: all diff --git a/testdata/extensions/cuda-requirement_v1_0.cwl b/testdata/extensions/cuda-requirement_v1_0.cwl new file mode 100644 index 00000000..21985e6c --- /dev/null +++ b/testdata/extensions/cuda-requirement_v1_0.cwl @@ -0,0 +1,16 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +class: CommandLineTool +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:CUDARequirement: + cudaVersionMin: "1.0" + cudaComputeCapability: "1.0" + cudaDeviceCountMin: $(inputs.gpus) +inputs: + gpus: + type: int + default: 1 +outputs: [] +baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/testdata/extensions/cuda-requirement_v1_1.cwl b/testdata/extensions/cuda-requirement_v1_1.cwl new file mode 100644 index 00000000..9c24f0fe --- /dev/null +++ b/testdata/extensions/cuda-requirement_v1_1.cwl @@ -0,0 +1,16 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.1 +class: CommandLineTool +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:CUDARequirement: + cudaVersionMin: "1.0" + cudaComputeCapability: "1.0" + cudaDeviceCountMin: $(inputs.gpus) +inputs: + gpus: + type: int + default: 1 +outputs: [] +baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/testdata/extensions/cuda-requirement_v1_2.cwl b/testdata/extensions/cuda-requirement_v1_2.cwl new file mode 100644 index 00000000..4f1ecbd8 --- /dev/null +++ b/testdata/extensions/cuda-requirement_v1_2.cwl @@ -0,0 +1,16 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.2 +class: CommandLineTool +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:CUDARequirement: + cudaVersionMin: "1.0" + cudaComputeCapability: "1.0" + cudaDeviceCountMin: $(inputs.gpus) +inputs: + gpus: + type: int + default: 1 +outputs: [] +baseCommand: "nvidia-smi" \ No newline at end of file diff --git a/testdata/extensions/inplace-update-requirement_v1_0.cwl b/testdata/extensions/inplace-update-requirement_v1_0.cwl new file mode 100644 index 00000000..14f72054 --- /dev/null +++ b/testdata/extensions/inplace-update-requirement_v1_0.cwl @@ -0,0 +1,21 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:InplaceUpdateRequirement: + inplaceUpdate: true +inputs: + r: File + script: + type: File + default: + class: File + location: updateval.py +outputs: + out: + type: File + outputBinding: + glob: $(inputs.r.basename) +arguments: [python, $(inputs.script), $(inputs.r.basename)] \ No newline at end of file diff --git a/testdata/extensions/load-listing-requirement_v1_0.cwl b/testdata/extensions/load-listing-requirement_v1_0.cwl new file mode 100644 index 00000000..36d67fb4 --- /dev/null +++ b/testdata/extensions/load-listing-requirement_v1_0.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: http://commonwl.org/cwltool# +requirements: + cwltool:LoadListingRequirement: + loadListing: shallow_listing +inputs: + d: Directory +outputs: [] +arguments: + [echo, "$(inputs.d.listing[0].listing[0])"] diff --git a/testdata/extensions/mpi-requirement_v1_0.cwl b/testdata/extensions/mpi-requirement_v1_0.cwl new file mode 100644 index 00000000..72dc680b --- /dev/null +++ b/testdata/extensions/mpi-requirement_v1_0.cwl @@ -0,0 +1,14 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" + +baseCommand: env +requirements: + cwltool:MPIRequirement: + processes: 1 +inputs: {} +outputs: + environment: + type: stdout \ No newline at end of file diff --git a/testdata/extensions/mpi-requirement_v1_1.cwl b/testdata/extensions/mpi-requirement_v1_1.cwl new file mode 100644 index 00000000..a4ad0fe1 --- /dev/null +++ b/testdata/extensions/mpi-requirement_v1_1.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.1 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +baseCommand: env +requirements: + cwltool:MPIRequirement: + processes: 1 +inputs: {} +outputs: + environment: + type: stdout \ No newline at end of file diff --git a/testdata/extensions/mpi-requirement_v1_2.cwl b/testdata/extensions/mpi-requirement_v1_2.cwl new file mode 100644 index 00000000..5790f414 --- /dev/null +++ b/testdata/extensions/mpi-requirement_v1_2.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.2 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +baseCommand: env +requirements: + cwltool:MPIRequirement: + processes: 1 +inputs: {} +outputs: + environment: + type: stdout \ No newline at end of file diff --git a/testdata/extensions/network-access_v1_0.cwl b/testdata/extensions/network-access_v1_0.cwl new file mode 100644 index 00000000..4152a116 --- /dev/null +++ b/testdata/extensions/network-access_v1_0.cwl @@ -0,0 +1,16 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:NetworkAccess: + networkAccess: true +inputs: [] +outputs: [] +baseCommand: python +arguments: + - "-c" + - valueFrom: | + import urllib.request + assert(urllib.request.urlopen("http://commonwl.org").code == 200) \ No newline at end of file diff --git a/testdata/extensions/process-generator_v1_0.cwl b/testdata/extensions/process-generator_v1_0.cwl new file mode 100644 index 00000000..01df6367 --- /dev/null +++ b/testdata/extensions/process-generator_v1_0.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +class: cwltool:ProcessGenerator +inputs: + script: string + dir: Directory +outputs: {} +run: + class: CommandLineTool + inputs: + script: string + dir: Directory + outputs: + runProcess: + type: File + outputBinding: + glob: main.cwl + requirements: + InlineJavascriptRequirement: {} + LoadListingRequirement: + loadListing: shallow_listing + InitialWorkDirRequirement: + listing: | + ${ + var v = inputs.dir.listing; + v.push({entryname: "inp.py", entry: inputs.script}); + return v; + } + arguments: [python3, inp.py] + stdout: main.cwl \ No newline at end of file diff --git a/testdata/extensions/process-generator_v1_1.cwl b/testdata/extensions/process-generator_v1_1.cwl new file mode 100644 index 00000000..b4ccc99c --- /dev/null +++ b/testdata/extensions/process-generator_v1_1.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.1 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +class: cwltool:ProcessGenerator +inputs: + script: string + dir: Directory +outputs: {} +run: + class: CommandLineTool + inputs: + script: string + dir: Directory + outputs: + runProcess: + type: File + outputBinding: + glob: main.cwl + requirements: + InlineJavascriptRequirement: {} + LoadListingRequirement: + loadListing: shallow_listing + InitialWorkDirRequirement: + listing: | + ${ + var v = inputs.dir.listing; + v.push({entryname: "inp.py", entry: inputs.script}); + return v; + } + arguments: [python3, inp.py] + stdout: main.cwl \ No newline at end of file diff --git a/testdata/extensions/process-generator_v1_2.cwl b/testdata/extensions/process-generator_v1_2.cwl new file mode 100644 index 00000000..62960a2f --- /dev/null +++ b/testdata/extensions/process-generator_v1_2.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.2 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +class: cwltool:ProcessGenerator +inputs: + script: string + dir: Directory +outputs: {} +run: + class: CommandLineTool + inputs: + script: string + dir: Directory + outputs: + runProcess: + type: File + outputBinding: + glob: main.cwl + requirements: + InlineJavascriptRequirement: {} + LoadListingRequirement: + loadListing: shallow_listing + InitialWorkDirRequirement: + listing: | + ${ + var v = inputs.dir.listing; + v.push({entryname: "inp.py", entry: inputs.script}); + return v; + } + arguments: [python3, inp.py] + stdout: main.cwl \ No newline at end of file diff --git a/testdata/extensions/secrets_v1_0.cwl b/testdata/extensions/secrets_v1_0.cwl new file mode 100644 index 00000000..63446512 --- /dev/null +++ b/testdata/extensions/secrets_v1_0.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +class: CommandLineTool +$namespaces: + cwltool: http://commonwl.org/cwltool# +requirements: + cwltool:Secrets: + secrets: [pw] +inputs: + pw: string +outputs: + out: stdout +arguments: [cat, example.conf] diff --git a/testdata/extensions/secrets_v1_1.cwl b/testdata/extensions/secrets_v1_1.cwl new file mode 100644 index 00000000..09d476f6 --- /dev/null +++ b/testdata/extensions/secrets_v1_1.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.1 +class: CommandLineTool +$namespaces: + cwltool: http://commonwl.org/cwltool# +requirements: + cwltool:Secrets: + secrets: [pw] +inputs: + pw: string +outputs: + out: stdout +arguments: [cat, example.conf] diff --git a/testdata/extensions/secrets_v1_2.cwl b/testdata/extensions/secrets_v1_2.cwl new file mode 100644 index 00000000..02d7dff6 --- /dev/null +++ b/testdata/extensions/secrets_v1_2.cwl @@ -0,0 +1,13 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.2 +class: CommandLineTool +$namespaces: + cwltool: http://commonwl.org/cwltool# +requirements: + cwltool:Secrets: + secrets: [pw] +inputs: + pw: string +outputs: + out: stdout +arguments: [cat, example.conf] diff --git a/testdata/extensions/shm-size_v1_0.cwl b/testdata/extensions/shm-size_v1_0.cwl new file mode 100644 index 00000000..01f90a44 --- /dev/null +++ b/testdata/extensions/shm-size_v1_0.cwl @@ -0,0 +1,15 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:ShmSize: + shmSize: 128m +inputs: [] +outputs: + output: + type: stdout +baseCommand: echo +stdout: shm-size.txt +arguments: [ $(runtime) ] diff --git a/testdata/extensions/shm-size_v1_1.cwl b/testdata/extensions/shm-size_v1_1.cwl new file mode 100644 index 00000000..3bff20df --- /dev/null +++ b/testdata/extensions/shm-size_v1_1.cwl @@ -0,0 +1,15 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.1 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:ShmSize: + shmSize: 128m +inputs: [] +outputs: + output: + type: stdout +baseCommand: echo +stdout: shm-size.txt +arguments: [ $(runtime) ] diff --git a/testdata/extensions/shm-size_v1_2.cwl b/testdata/extensions/shm-size_v1_2.cwl new file mode 100644 index 00000000..b6491432 --- /dev/null +++ b/testdata/extensions/shm-size_v1_2.cwl @@ -0,0 +1,15 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.2 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:ShmSize: + shmSize: 128m +inputs: [] +outputs: + output: + type: stdout +baseCommand: echo +stdout: shm-size.txt +arguments: [ $(runtime) ] diff --git a/testdata/extensions/single-var-loop_v1_2.cwl b/testdata/extensions/single-var-loop_v1_2.cwl new file mode 100644 index 00000000..c5f76563 --- /dev/null +++ b/testdata/extensions/single-var-loop_v1_2.cwl @@ -0,0 +1,32 @@ +#!/usr/bin/env cwl-runner +cwlVersion: v1.2 +class: Workflow +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + InlineJavascriptRequirement: {} +inputs: + i1: int +outputs: + o1: + type: int + outputSource: subworkflow/o1 +steps: + subworkflow: + run: + class: ExpressionTool + inputs: + i1: int + outputs: + o1: int + expression: > + ${return {'o1': inputs.i1 + 1};} + in: + i1: i1 + out: [o1] + requirements: + cwltool:Loop: + loopWhen: $(inputs.i1 < 10) + loop: + i1: o1 + outputMethod: last diff --git a/testdata/extensions/time-limit_v1_0.cwl b/testdata/extensions/time-limit_v1_0.cwl new file mode 100644 index 00000000..7106a934 --- /dev/null +++ b/testdata/extensions/time-limit_v1_0.cwl @@ -0,0 +1,15 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +inputs: + sleep_time: + type: int + default: 3 + inputBinding: {} +outputs: [] +requirements: + cwltool:TimeLimit: + timelimit: 20 +baseCommand: sleep \ No newline at end of file diff --git a/testdata/extensions/work-reuse_v1_0.cwl b/testdata/extensions/work-reuse_v1_0.cwl new file mode 100644 index 00000000..7278cb2b --- /dev/null +++ b/testdata/extensions/work-reuse_v1_0.cwl @@ -0,0 +1,18 @@ +#!/usr/bin/env cwl-runner +class: CommandLineTool +cwlVersion: v1.0 +$namespaces: + cwltool: "http://commonwl.org/cwltool#" +requirements: + cwltool:WorkReuse: + enableReuse: false +inputs: [] +outputs: + page: stdout +stdout: time.txt +baseCommand: python +arguments: + - "-c" + - valueFrom: | + import time + print(time.time()) diff --git a/tests/test_extensions.py b/tests/test_extensions.py new file mode 100644 index 00000000..ab4a0f43 --- /dev/null +++ b/tests/test_extensions.py @@ -0,0 +1,204 @@ +from pathlib import Path + +from cwl_utils.parser import cwl_v1_0, cwl_v1_1, cwl_v1_2, load_document_by_uri + +from .util import get_data + + +def test_cuda_requirement_v1_0() -> None: + """Test that CUDARequirement objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/cuda-requirement_v1_0.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.CUDARequirement) + + +def test_cuda_requirement_v1_1() -> None: + """Test that CUDARequirement objects are correctly loaded for CWL v1.1.""" + uri = ( + Path(get_data("testdata/extensions/cuda-requirement_v1_1.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.CUDARequirement) + + +def test_cuda_requirement_v1_2() -> None: + """Test that CUDARequirement objects are correctly loaded for CWL v1.2.""" + uri = ( + Path(get_data("testdata/extensions/cuda-requirement_v1_2.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.CUDARequirement) + + +def test_load_listing_requirement_v1_0() -> None: + """Test that LoadListingRequirement objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/load-listing-requirement_v1_0.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.LoadListingRequirement) + + +def test_loop_v1_2() -> None: + """Test that Loop and LoopInput objects are correctly loaded for CWL v1.2.""" + uri = ( + Path(get_data("testdata/extensions/single-var-loop_v1_2.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + cwl_step = next(iter(cwl_obj.steps)) + loop_req = next(iter(cwl_step.requirements)) + assert isinstance(loop_req, cwl_v1_2.Loop) + assert isinstance(next(iter(loop_req.loop)), cwl_v1_2.LoopInput) + + +def test_inplace_update_requirement_v1_0() -> None: + """Test that InplaceUpdateRequirement objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/inplace-update-requirement_v1_0.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance( + next(iter(cwl_obj.requirements)), cwl_v1_0.InplaceUpdateRequirement + ) + + +def test_mpi_requirement_v1_0() -> None: + """Test that MPIRequirement objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/mpi-requirement_v1_0.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.MPIRequirement) + + +def test_mpi_requirement_v1_1() -> None: + """Test that MPIRequirement objects are correctly loaded for CWL v1.1.""" + uri = ( + Path(get_data("testdata/extensions/mpi-requirement_v1_1.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.MPIRequirement) + + +def test_mpi_requirement_v1_2() -> None: + """Test that MPIRequirement objects are correctly loaded for CWL v1.2.""" + uri = ( + Path(get_data("testdata/extensions/mpi-requirement_v1_2.cwl")) + .resolve() + .as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.MPIRequirement) + + +def test_network_access_v1_0() -> None: + """Test that NetworkAccess objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/network-access_v1_0.cwl")).resolve().as_uri() + ) + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.NetworkAccess) + + +def test_process_generator_v1_0() -> None: + """Test that ProcessGenerator objects are correctly loaded for CWL v1.0.""" + uri = ( + Path(get_data("testdata/extensions/process-generator_v1_0.cwl")) + .resolve() + .as_uri() + ) + assert isinstance(load_document_by_uri(uri), cwl_v1_0.ProcessGenerator) + + +def test_process_generator_v1_1() -> None: + """Test that ProcessGenerator objects are correctly loaded for CWL v1.1.""" + uri = ( + Path(get_data("testdata/extensions/process-generator_v1_1.cwl")) + .resolve() + .as_uri() + ) + assert isinstance(load_document_by_uri(uri), cwl_v1_1.ProcessGenerator) + + +def test_process_generator_v1_2() -> None: + """Test that ProcessGenerator objects are correctly loaded for CWL v1.2.""" + uri = ( + Path(get_data("testdata/extensions/process-generator_v1_2.cwl")) + .resolve() + .as_uri() + ) + assert isinstance(load_document_by_uri(uri), cwl_v1_2.ProcessGenerator) + + +def test_secrets_v1_0() -> None: + """Test that Secrets objects are correctly loaded for CWL v1.0.""" + uri = Path(get_data("testdata/extensions/secrets_v1_0.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.Secrets) + + +def test_secrets_v1_1() -> None: + """Test that Secrets objects are correctly loaded for CWL v1.1.""" + uri = Path(get_data("testdata/extensions/secrets_v1_1.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.Secrets) + + +def test_secrets_v1_2() -> None: + """Test that Secrets objects are correctly loaded for CWL v1.2.""" + uri = Path(get_data("testdata/extensions/secrets_v1_2.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.Secrets) + + +def test_shm_size_v1_0() -> None: + """Test that ShmSize objects are correctly loaded for CWL v1.0.""" + uri = Path(get_data("testdata/extensions/shm-size_v1_0.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.ShmSize) + + +def test_shm_size_v1_1() -> None: + """Test that ShmSize objects are correctly loaded for CWL v1.1.""" + uri = Path(get_data("testdata/extensions/shm-size_v1_1.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_1.ShmSize) + + +def test_shm_size_v1_2() -> None: + """Test that ShmSize objects are correctly loaded for CWL v1.2.""" + uri = Path(get_data("testdata/extensions/shm-size_v1_2.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_2.ShmSize) + + +def test_time_limit_v1_0() -> None: + """Test that TimeLimit objects are correctly loaded for CWL v1.0.""" + uri = Path(get_data("testdata/extensions/time-limit_v1_0.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.TimeLimit) + + +def test_work_reuse_v1_0() -> None: + """Test that WorkReuse objects are correctly loaded for CWL v1.0.""" + uri = Path(get_data("testdata/extensions/work-reuse_v1_0.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + assert isinstance(next(iter(cwl_obj.requirements)), cwl_v1_0.WorkReuse) diff --git a/tests/test_parser_utils.py b/tests/test_parser_utils.py index e52302a5..8c16b004 100644 --- a/tests/test_parser_utils.py +++ b/tests/test_parser_utils.py @@ -103,6 +103,8 @@ def test_static_checker_success(cwlVersion: str) -> None: "testdata/cond-wf-004.1.cwl", "testdata/cond-wf-005.1.cwl", "testdata/cond-single-source-wf-005.1.cwl", + "testdata/extensions/all-output-loop_v1_2.cwl", + "testdata/extensions/single-var-loop_v1_2.cwl", ] ) for test_file in test_files: