Skip to content

Commit cf846bc

Browse files
authored
Merge branch 'main' into pa/cwlutil-validator
2 parents b00b17e + 2a2216b commit cf846bc

29 files changed

+124
-41
lines changed

.github/workflows/ci-tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,43 @@ jobs:
184184
- uses: actions/checkout@v3
185185
- name: build & test cwltool_module container
186186
run: ./build-cwltool-docker.sh
187+
188+
macos:
189+
name: CI test on macos-latest
190+
runs-on: macos-latest
191+
env:
192+
TOXENV: py310-unit
193+
steps:
194+
- uses: actions/checkout@v3
195+
with:
196+
fetch-depth: 0
197+
- name: Set up Python
198+
uses: actions/setup-python@v4
199+
with:
200+
python-version: "3.10"
201+
cache: pip
202+
cache-dependency-path: |
203+
requirements.txt
204+
tox.ini
205+
- name: Upgrade setuptools and install tox
206+
run: |
207+
pip install -U pip setuptools wheel
208+
pip install tox tox-gh-actions
209+
# # docker for mac install is not currently stable
210+
# - name: 'SETUP MacOS: load Homebrew cache'
211+
# uses: actions/cache@v3
212+
# if: runner.os == 'macOS'
213+
# with:
214+
# path: |
215+
# ~/Library/Caches/Homebrew/downloads/*--Docker.dmg
216+
# key: brew-actions-setup-docker-1.0.11
217+
# restore-keys: brew-actions-setup-docker-
218+
# - name: setup docker on macos (default stable version)
219+
# uses: docker-practice/actions-setup-docker@master
220+
- name: Test with tox
221+
run: tox
222+
- name: Upload coverage to Codecov
223+
if: ${{ matrix.step == 'unit' }}
224+
uses: codecov/codecov-action@v3
225+
with:
226+
fail_ci_if_error: true

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ For the more traditional workflow:
3131
- To begin using the virtual environment, it needs to be activated: `source venv/bin/activate`
3232
- To check if you have the virtual environment set up: `which python`
3333
and it should point to python executable in your virtualenv
34+
- Install the latest versions of `pip` and `wheel` with `pip install --upgrade pip wheel`
3435
- Install cwltool in development mode, along with development tools:
3536
`make install-dep dev`
3637
- Check the `cwltool` version which might be different from the version installed in

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ diff-cover: coverage.xml
157157
diff-cover.html: coverage.xml
158158
diff-cover --compare-branch=main $^ --html-report $@
159159

160-
## test : run the ${MODULE} test suite
160+
## test : run the cwltool test suite
161161
test: check-python3 $(PYSOURCES)
162162
python -m pytest -rs ${PYTEST_EXTRA}
163163

164-
## testcov : run the ${MODULE} test suite and collect coverage
164+
## testcov : run the cwltool test suite and collect coverage
165165
testcov: check-python3 $(PYSOURCES)
166166
python -m pytest -rs --cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA}
167167

build-cwltool-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ docker run -t -v /var/run/docker.sock:/var/run/docker.sock \
77
-v /tmp:/tmp \
88
-v "$PWD":/tmp/cwltool \
99
quay.io/commonwl/cwltool_module /bin/sh -c \
10-
"apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not (test_bioconda or test_double_overwrite or test_env_filtering or test_biocontainers or test_disable_file_overwrite_without_ext or test_disable_file_creation_in_outdir_with_ext or test_write_write_conflict or test_directory_literal_with_real_inputs_inside or test_revsort_workflow or test_stdin_with_id_preset)' --ignore-glob '*test_udocker.py' -n auto -v -rs --pyargs cwltool"
10+
"apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not (test_bioconda or test_double_overwrite or test_env_filtering or test_biocontainers or test_disable_file_overwrite_without_ext or test_disable_file_creation_in_outdir_with_ext or test_write_write_conflict or test_directory_literal_with_real_inputs_inside or test_revsort_workflow or test_stdin_with_id_preset or test_no_compute_chcksum or test_packed_workflow_execution[tests/wf/count-lines1-wf.cwl-tests/wf/wc-job.json-False] or test_sequential_workflow or test_single_process_subwf_subwf_inline_step)' --ignore-glob '*test_udocker.py' -n 0 -v -rs --pyargs cwltool"

cwltool/argparser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import urllib
66
from typing import (
77
Any,
8-
AnyStr,
98
Callable,
109
Dict,
1110
List,
@@ -18,8 +17,6 @@
1817
cast,
1918
)
2019

21-
from schema_salad.ref_resolver import file_uri
22-
2320
from .loghandler import _logger
2421
from .process import Process, shortname
2522
from .resolver import ga4gh_tool_registries

cwltool/command_line_tool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from functools import cmp_to_key, partial
1616
from typing import (
1717
Any,
18-
Callable,
1918
Dict,
2019
Generator,
2120
List,

cwltool/cuda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import subprocess # nosec
22
import xml.dom.minidom # nosec
3-
from typing import Tuple, cast
3+
from typing import Tuple
44

55
from .loghandler import _logger
66
from .utils import CWLObjectType

cwltool/docker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from .builder import Builder
1818
from .context import RuntimeContext
19-
from .cuda import cuda_check
2019
from .docker_id import docker_vm_id
2120
from .errors import WorkflowException
2221
from .job import ContainerCommandLineJob

cwltool/provenance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def __init__(
298298
self.cwltool_version = "cwltool %s" % versionstring().split()[-1]
299299
##
300300
self.relativised_input_object = {} # type: CWLObjectType
301+
self.has_manifest = False
301302

302303
self._initialize()
303304
_logger.debug("[provenance] Temporary research object: %s", self.folder)
@@ -355,6 +356,8 @@ def open_log_file_for_activity(
355356
def _finalize(self) -> None:
356357
self._write_ro_manifest()
357358
self._write_bag_info()
359+
if not self.has_manifest:
360+
(Path(self.folder) / "manifest-sha1.txt").touch()
358361

359362
def user_provenance(self, document: ProvDocument) -> None:
360363
"""Add the user provenance."""
@@ -853,6 +856,7 @@ def add_to_manifest(self, rel_path: str, checksums: Dict[str, str]) -> None:
853856
if os.path.commonprefix(["data/", rel_path]) == "data/":
854857
# payload file, go to manifest
855858
manifest = "manifest"
859+
self.has_manifest = True
856860
else:
857861
# metadata file, go to tag manifest
858862
manifest = "tagmanifest"

cwltool/provenance_profile.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020
)
2121

2222
from prov.identifier import Identifier, QualifiedName
23-
from prov.model import (
24-
PROV,
25-
PROV_LABEL,
26-
PROV_TYPE,
27-
PROV_VALUE,
28-
ProvDocument,
29-
ProvEntity,
30-
ProvRecord,
31-
)
23+
from prov.model import PROV, PROV_LABEL, PROV_TYPE, PROV_VALUE, ProvDocument, ProvEntity
3224
from schema_salad.sourceline import SourceLine
3325
from typing_extensions import TYPE_CHECKING
3426

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"cwl-utils @ https://github.com/common-workflow-language/cwl-utils/archive/codegen-fixes.zip",
125125
],
126126
extras_require={
127-
"deps": ["galaxy-tool-util >= 21.1.0"],
127+
"deps": ["galaxy-tool-util >= 22.1.2, <23"],
128128
},
129129
python_requires=">=3.6, <4",
130130
setup_requires=PYTEST_RUNNER,

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pytest-cov
77
arcp >= 0.2.0
88
rdflib-jsonld>=0.4.0, <= 0.6.1;python_version<='3.6'
99
-rrequirements.txt
10-
galaxy-tool-util >= 21.1.0
10+
galaxy-tool-util >= 22.1.2, < 23

tests/checker_wf/wc.cwl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env cwl-runner
22
cwlVersion: v1.1
33
class: CommandLineTool
4+
hints:
5+
DockerRequirement:
6+
dockerPull: docker.io/debian:stable-slim
47
inputs:
58
intxt:
69
type: File

tests/subgraph/count-lines17-wf.cwl.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
"-l"
114114
],
115115
"class": "CommandLineTool",
116+
"hints": {
117+
"DockerRequirement": {
118+
"dockerPull": "docker.io/debian:stable-slim"
119+
}
120+
},
116121
"id": "count-lines17-wf.cwl@step_step1@run@step_stepX@run@step_stepY@run",
117122
"inputs": [
118123
{

tests/subgraph/wc-tool.cwl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
class: CommandLineTool
44
cwlVersion: v1.0
55

6+
hints:
7+
DockerRequirement:
8+
dockerPull: docker.io/debian:stable-slim
9+
610
inputs:
711
file1: File
812

tests/test_cuda.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from cwltool.job import CommandLineJob
1212
from cwltool.load_tool import load_tool
1313
from cwltool.main import main
14-
from cwltool.pathmapper import MapperEnt, PathMapper
15-
from cwltool.process import use_custom_schema, use_standard_schema
14+
from cwltool.pathmapper import PathMapper
15+
from cwltool.process import use_custom_schema
1616
from cwltool.stdfsaccess import StdFsAccess
17-
from cwltool.update import INTERNAL_VERSION, ORIGINAL_CWLVERSION
17+
from cwltool.update import INTERNAL_VERSION
1818
from cwltool.utils import CWLObjectType
1919

2020
from .util import get_data, needs_docker, needs_singularity_3_or_newer

tests/test_dependencies.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
import pytest
99

10+
from cwltool.context import LoadingContext
11+
from cwltool.load_tool import load_tool
12+
from cwltool.software_requirements import get_container_from_software_requirements
13+
1014
from .util import get_data, get_main_output, get_tool_env, needs_docker
1115

1216
deps = None # type: Optional[ModuleType]
@@ -28,6 +32,17 @@ def test_biocontainers(tmp_path: Path) -> None:
2832
assert error_code == 0
2933

3034

35+
@needs_docker
36+
@pytest.mark.skipif(not deps, reason="galaxy-tool-util is not installed")
37+
def test_biocontainers_resolution(tmp_path: Path) -> None:
38+
"""Confirm expected container name for --beta-use-biocontainers."""
39+
tool = load_tool(get_data("tests/seqtk_seq.cwl"), LoadingContext())
40+
assert (
41+
get_container_from_software_requirements(True, tool)
42+
== "quay.io/biocontainers/seqtk:r93--0"
43+
)
44+
45+
3146
@pytest.mark.skipif(not deps, reason="galaxy-tool-util is not installed")
3247
def test_bioconda(tmp_path: Path) -> None:
3348
wflow = get_data("tests/seqtk_seq.cwl")

tests/test_examples.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ def test_static_checker() -> None:
910910
factory.make(get_data("tests/checker_wf/broken-wf3.cwl"))
911911

912912

913+
@needs_docker
913914
def test_circular_dependency_checker() -> None:
914915
# check that the circular dependency checker raises exception when there is
915916
# circular dependency in the workflow.
@@ -1119,8 +1120,9 @@ def test_cid_file_dir(tmp_path: Path, factor: str) -> None:
11191120
stderr = re.sub(r"\s\s+", " ", stderr)
11201121
assert "completed success" in stderr
11211122
assert error_code == 0
1122-
cidfiles_count = sum(1 for _ in tmp_path.glob("**/*"))
1123-
assert cidfiles_count == 2
1123+
cidfiles = list(tmp_path.glob("**/*.cid"))
1124+
cidfiles_count = len(cidfiles)
1125+
assert cidfiles_count == 2, f"Should be 2 cidfiles, but got {cidfiles}"
11241126

11251127

11261128
@needs_docker
@@ -1449,6 +1451,7 @@ def test_no_compute_chcksum(tmp_path: Path, factor: str) -> None:
14491451
assert "checksum" not in stdout
14501452

14511453

1454+
@needs_docker
14521455
@pytest.mark.parametrize("factor", test_factors)
14531456
def test_bad_userspace_runtime(factor: str) -> None:
14541457
test_file = "tests/wf/wc-tool.cwl"

tests/test_iwdr.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def test_iwdr_permutations(tmp_path_factory: Any) -> None:
131131
)
132132
assert err_code == 0
133133
log = json.loads(stdout)["log"]
134-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
134+
with open(log["path"]) as log_h:
135+
log_text = log_h.read()
136+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
135137

136138

137139
def test_iwdr_permutations_readonly(tmp_path_factory: Any) -> None:
@@ -240,7 +242,9 @@ def test_iwdr_permutations_inplace(tmp_path_factory: Any) -> None:
240242
)
241243
assert err_code == 0
242244
log = json.loads(stdout)["log"]
243-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
245+
with open(log["path"]) as log_h:
246+
log_text = log_h.read()
247+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
244248

245249

246250
@needs_singularity
@@ -298,7 +302,9 @@ def test_iwdr_permutations_singularity(tmp_path_factory: Any) -> None:
298302
)
299303
assert err_code == 0
300304
log = json.loads(stdout)["log"]
301-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
305+
with open(log["path"]) as log_h:
306+
log_text = log_h.read()
307+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
302308

303309

304310
@needs_singularity

tests/test_misc_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from cwltool.utils import versionstring
44

5-
from .util import get_data, get_main_output
5+
from .util import get_data, get_main_output, needs_docker
66

77

88
def test_version() -> None:
@@ -44,6 +44,7 @@ def test_basic_pack() -> None:
4444
assert "$graph" in stdout
4545

4646

47+
@needs_docker
4748
def test_basic_print_subgraph() -> None:
4849
"""Basic test of --print-subgraph. See test_subgraph.py for detailed testing."""
4950
return_code, stdout, stderr = get_main_output(

tests/test_parallel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
from cwltool.executors import MultithreadedJobExecutor
66
from cwltool.factory import Factory
77

8-
from .util import get_data
8+
from .util import get_data, needs_docker
99

1010

11+
@needs_docker
1112
def test_sequential_workflow(tmp_path: Path) -> None:
1213
test_file = "tests/wf/count-lines1-wf.cwl"
1314
executor = MultithreadedJobExecutor()
@@ -20,6 +21,7 @@ def test_sequential_workflow(tmp_path: Path) -> None:
2021
assert echo(file1=file_contents) == {"count_output": 16}
2122

2223

24+
@needs_docker
2325
def test_scattered_workflow() -> None:
2426
test_file = "tests/wf/scatter-wf4.cwl"
2527
job_file = "tests/wf/scatter-job2.json"

tests/test_provenance.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,15 @@ def test_directory_workflow(tmp_path: Path) -> None:
192192
assert p.is_file(), f"Could not find {l} as {p}"
193193

194194

195+
@needs_docker
196+
def test_no_data_files(tmp_path: Path) -> None:
197+
folder = cwltool(
198+
tmp_path,
199+
get_data("tests/wf/conditional_step_no_inputs.cwl"),
200+
)
201+
check_bagit(folder)
202+
203+
195204
def check_output_object(base_path: Path) -> None:
196205
output_obj = base_path / "workflow" / "primary-output.json"
197206
compare_checksum = "sha1$b9214658cc453331b62c2282b772a5c063dbd284"

tests/test_stdout_stderr_log_dir.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import json
2-
import os
32
from pathlib import Path
43

5-
from cwltool.main import main
6-
7-
from .util import get_data, get_main_output, needs_docker
4+
from .util import get_data, get_main_output
85

96

107
def test_log_dir_echo_output(tmp_path: Path) -> None:

tests/test_subgraph.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def test_single_process_packed_subwf_step(tmp_path: Path) -> None:
240240
)
241241

242242

243+
@needs_docker
243244
def test_single_process_subwf_subwf_inline_step() -> None:
244245
"""Test --single-process on an inline sub-sub-workflow step."""
245246
err_code, stdout, stderr = get_main_output(
@@ -350,6 +351,7 @@ def test_print_targets_embedded_reqsinherit() -> None:
350351
assert err_code == 0
351352

352353

354+
@needs_docker
353355
def test_print_targets_embedded_sub_subwfs() -> None:
354356
"""Confirm that --print-targets works with inline sub-sub-workflows."""
355357
err_code, stdout, stderr = get_main_output(

tests/test_toolargparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
from io import StringIO
33
from pathlib import Path
4-
from typing import Any, Callable, Dict, List
4+
from typing import Callable, List
55

66
import pytest
77

0 commit comments

Comments
 (0)