Skip to content

Commit 8edabf8

Browse files
committed
Merge remote-tracking branch 'origin/main' into input_annotations
2 parents c13e26a + bcdbeaf commit 8edabf8

File tree

9 files changed

+67
-17
lines changed

9 files changed

+67
-17
lines changed

.github/workflows/ci-tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run: sudo usermod -c 'CI Runner' "$(whoami)"
5656

5757
- name: Set up Python
58-
uses: actions/setup-python@v4
58+
uses: actions/setup-python@v5
5959
with:
6060
python-version: ${{ env.py-semver }}
6161
allow-prereleases: true
@@ -104,7 +104,7 @@ jobs:
104104
fetch-depth: 0
105105

106106
- name: Set up Python
107-
uses: actions/setup-python@v4
107+
uses: actions/setup-python@v5
108108
with:
109109
python-version: ${{ env.py-semver }}
110110
cache: pip
@@ -140,7 +140,7 @@ jobs:
140140
run: sudo usermod -c 'CI Runner' "$(whoami)"
141141

142142
- name: Set up Python
143-
uses: actions/setup-python@v4
143+
uses: actions/setup-python@v5
144144
with:
145145
python-version: ${{ env.py-semver }}
146146
cache: pip
@@ -194,7 +194,7 @@ jobs:
194194
run: sudo rm -f /usr/bin/docker ; sudo apt-get install -y podman
195195

196196
- name: Set up Python
197-
uses: actions/setup-python@v4
197+
uses: actions/setup-python@v5
198198
with:
199199
python-version: 3.12
200200
cache: pip
@@ -207,7 +207,7 @@ jobs:
207207
CWLTOOL_OPTIONS: ${{ matrix.cwl-version == 'v1.2' && '--relax-path-checks' || '' }} ${{ matrix.extras }}
208208
run: ./conformance-test.sh
209209
- name: Archive test results
210-
uses: actions/upload-artifact@v3
210+
uses: actions/upload-artifact@v4
211211
with:
212212
name: cwl-${{ matrix.cwl-version }}-${{ matrix.container }}${{ matrix.extras }}-conformance-results
213213
path: |
@@ -230,7 +230,7 @@ jobs:
230230
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb
231231
232232
- name: Set up Python
233-
uses: actions/setup-python@v4
233+
uses: actions/setup-python@v5
234234
with:
235235
python-version: 3.12
236236
cache: pip
@@ -272,7 +272,7 @@ jobs:
272272
with:
273273
fetch-depth: 0
274274
- name: Set up Python
275-
uses: actions/setup-python@v4
275+
uses: actions/setup-python@v5
276276
with:
277277
python-version: 3.12
278278
cache: pip

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727

2828
# Initializes the CodeQL tools for scanning.
2929
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@v2
30+
uses: github/codeql-action/init@v3
3131
with:
3232
languages: python
3333

3434
- name: Perform CodeQL Analysis
35-
uses: github/codeql-action/analyze@v2
35+
uses: github/codeql-action/analyze@v3

conformance-test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ else
7676
venv "${TMP_DIR}/cwl-conformance-venv"
7777
pip install -U setuptools wheel pip
7878
pip uninstall -y cwltool
79-
pip install "${SCRIPT_DIRECTORY}" -r"${SCRIPT_DIRECTORY}/requirements.txt"
79+
pip install -r"${SCRIPT_DIRECTORY}/mypy-requirements.txt"
80+
CWLTOOL_USE_MYPYC=1 MYPYPATH="${SCRIPT_DIRECTORY}/mypy-stubs" pip install "${SCRIPT_DIRECTORY}" -r"${SCRIPT_DIRECTORY}/requirements.txt"
8081
pip install 'cwltest>=2.3' pytest-cov pytest-xdist
8182
fi
8283

cwltool/command_line_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def calc_checksum(location: str) -> Optional[str]:
866866
and "checksum" in e
867867
and e["checksum"] != "sha1$hash"
868868
):
869-
return cast(Optional[str], e["checksum"])
869+
return cast(str, e["checksum"])
870870
return None
871871

872872
def remove_prefix(s: str, prefix: str) -> str:

cwltool/process.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,10 +1342,15 @@ def compute_checksums(fs_access: StdFsAccess, fileobj: CWLObjectType) -> None:
13421342
if "checksum" not in fileobj:
13431343
checksum = hashlib.sha1() # nosec
13441344
location = cast(str, fileobj["location"])
1345-
with fs_access.open(location, "rb") as f:
1346-
contents = f.read(1024 * 1024)
1347-
while contents != b"":
1348-
checksum.update(contents)
1345+
if "contents" in fileobj:
1346+
contents = cast(str, fileobj["contents"]).encode("utf-8")
1347+
checksum.update(contents)
1348+
fileobj["size"] = len(contents)
1349+
else:
1350+
with fs_access.open(location, "rb") as f:
13491351
contents = f.read(1024 * 1024)
1352+
while contents != b"":
1353+
checksum.update(contents)
1354+
contents = f.read(1024 * 1024)
1355+
fileobj["size"] = fs_access.size(location)
13501356
fileobj["checksum"] = "sha1$%s" % checksum.hexdigest()
1351-
fileobj["size"] = fs_access.size(location)

lint-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
flake8-bugbear<23.13
2-
black~=23.11
2+
black~=23.12
33
codespell

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"argcomplete",
116116
"pyparsing != 3.0.2", # breaks --print-dot (pydot) https://github.com/pyparsing/pyparsing/issues/319
117117
"cwl-utils >= 0.32",
118+
"spython >= 0.3.0",
118119
],
119120
extras_require={
120121
"deps": [

tests/test_examples.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,28 @@ def test_cache_relative_paths(tmp_path: Path, factor: str) -> None:
13251325
assert (tmp_path / "cwltool_cache" / "27903451fc1ee10c148a0bdeb845b2cf").exists()
13261326

13271327

1328+
@pytest.mark.parametrize("factor", test_factors)
1329+
def test_cache_default_literal_file(tmp_path: Path, factor: str) -> None:
1330+
"""Confirm that running a CLT with a default literal file with caching succeeds."""
1331+
test_file = "tests/wf/extract_region_specs.cwl"
1332+
cache_dir = str(tmp_path / "cwltool_cache")
1333+
commands = factor.split()
1334+
commands.extend(
1335+
[
1336+
"--out",
1337+
str(tmp_path / "out"),
1338+
"--cachedir",
1339+
cache_dir,
1340+
get_data(test_file),
1341+
]
1342+
)
1343+
error_code, _, stderr = get_main_output(commands)
1344+
1345+
stderr = re.sub(r"\s\s+", " ", stderr)
1346+
assert "completed success" in stderr
1347+
assert error_code == 0
1348+
1349+
13281350
def test_write_summary(tmp_path: Path) -> None:
13291351
"""Test --write-summary."""
13301352
commands = [

tests/wf/extract_region_specs.cwl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"cwlVersion": "v1.0",
3+
"class": "CommandLineTool",
4+
"inputs": [
5+
{
6+
"type": "File",
7+
"default": {
8+
"class": "File",
9+
"basename": "extract_regions.py",
10+
"contents": "#!/usr/bin/env python3\n\nfrom __future__ import print_function, division\nimport sys\n\ninput_filename = sys.argv[1]\nif len(sys.argv) == 3:\n fuzz = int(sys.argv[2])\nelse:\n fuzz = 0\ninput_file = open(input_filename)\n\ncount = 0\nfor line in input_file:\n if not line.startswith(\">\"):\n continue\n count += 1\n contig_regions_file = open(\"contig_regions{}.txt\".format(count), \"w\")\n proteins_list_file = open(\"proteins{}.txt\".format(count), \"w\")\n fields = line.split(\"|\")\n protein_id = fields[0][1:]\n contig_id = fields[1]\n r_start = int(fields[6])\n if r_start > fuzz:\n r_start = r_start - fuzz\n r_end = int(fields[7]) + fuzz\n print(\"{}:{}-{}\".format(contig_id, r_start, r_end), file=contig_regions_file)\n print(protein_id, file=proteins_list_file)\n contig_regions_file.close()\n proteins_list_file.close()\n"
11+
},
12+
"inputBinding": {
13+
"position": 1
14+
},
15+
"id": "scripts"
16+
}
17+
],
18+
"outputs": [
19+
],
20+
"baseCommand": "cat"
21+
}

0 commit comments

Comments
 (0)