Repository navigation
Fix loadContents for file array in step input (#2339) - #2340
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2340 +/- ##
==========================================
+ Coverage 85.22% 85.26% +0.03%
==========================================
Files 46 46
Lines 8622 8624 +2
Branches 2020 2021 +1
==========================================
+ Hits 7348 7353 +5
+ Misses 809 806 -3
Partials 465 465 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
98e85b3 to
889394a
Compare
889394a to
10174db
Compare
|
I improved the tests to cover for the |
|
@CGuichard Here is a commit to fix the From de3ca8ee8bfe65d5ed1b3dd0658023a42918ffe1 Mon Sep 17 00:00:00 2001
From: "Michael R. Crusoe" <[email protected]>
Date: Sat, 12 Sep 2026 14:00:34 +0200
Subject: [PATCH] skip test if in mypyc-compiled build.
---
tests/test_load_contents.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/test_load_contents.py b/tests/test_load_contents.py
index 565b2507..c0083042 100644
--- a/tests/test_load_contents.py
+++ b/tests/test_load_contents.py
@@ -4,7 +4,9 @@ import json
from pathlib import Path
from unittest.mock import patch
-from cwltool.builder import content_limit_respected_read
+import pytest
+
+import cwltool.builder
from cwltool.main import main
from .util import get_data
@@ -24,6 +26,10 @@ def test_load_contents_file_array(tmp_path: Path) -> None:
assert data == {"data": [1, 2]}
+@pytest.mark.skipif(
+ not cwltool.builder.__file__.endswith(".py"),
+ reason="Does not work if in a mypyc-compiled build.",
+)
def test_load_contents_file_array_for_step_input(tmp_path: Path) -> None:
"""Ensures that a File[] in a step input with loadContents loads each file."""
params = [
@@ -33,7 +39,8 @@ def test_load_contents_file_array_for_step_input(tmp_path: Path) -> None:
]
with patch(
- "cwltool.workflow_job.content_limit_respected_read", wraps=content_limit_respected_read
+ "cwltool.workflow_job.content_limit_respected_read",
+ wraps=cwltool.builder.content_limit_respected_read,
) as mock_read:
assert main(params) == 0
assert mock_read.call_count == 2 # Exactly 2 files should be read
@@ -43,6 +50,10 @@ def test_load_contents_file_array_for_step_input(tmp_path: Path) -> None:
assert data == {"data": [1, 2]}
+@pytest.mark.skipif(
+ not cwltool.builder.__file__.endswith(".py"),
+ reason="Does not work if in a mypyc-compiled build.",
+)
def test_load_contents_file_array_for_step_input_with_preloaded_contents(tmp_path: Path) -> None:
"""Ensures that loadContents skips re-reading files whose contents are already set."""
params = [
@@ -53,7 +64,8 @@ def test_load_contents_file_array_for_step_input_with_preloaded_contents(tmp_pat
]
with patch(
- "cwltool.workflow_job.content_limit_respected_read", wraps=content_limit_respected_read
+ "cwltool.workflow_job.content_limit_respected_read",
+ wraps=cwltool.builder.content_limit_respected_read,
) as mock_read:
assert main(params) == 0
mock_read.assert_not_called() # Should not read from disk when contents already present
--
2.47.3 |
10174db to
62f2cb5
Compare
|
@mr-c Unfortunately it seems I don't have the checkbox to allow edit from maintainers because the fork is hosted in an organization (https://github.com/csgroup-oss), and the documentation says "On user-owned forks". I didn't find any way to enable this feature for this PR, so I merged your fix in the commit. |
Closes #2339
I moved the file contents read in a loop to be able to load 1..N files wether the step input is a list or not.
There was already a valid test about
loadContentswith File array, but it was only checking the loadContents for an input's inputBinding, meanwhile here we are in a different use case with workflow step inputs.cwltool/cwltool/builder.py
Lines 374 to 385 in baefdcb