Skip to content

Commit 28086cf

Browse files
authored
fix(cli): fix special paths in workflow files and bump toil/cwltool (#3489)
1 parent fbb7fcb commit 28086cf

File tree

8 files changed

+299
-60
lines changed

8 files changed

+299
-60
lines changed

poetry.lock

Lines changed: 264 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ click-option-group = "<0.6.0,>=0.5.2"
6161
click-plugins = "==1.1.1"
6262
coverage = { version = "<6.5,>=4.5.3", extras=["toml"], optional = true }
6363
cryptography = ">=38.0.0,<41.0.0"
64-
cwl-utils = ">=0.12,<0.18"
65-
cwltool = "==3.1.20220628170238"
64+
cwl-utils = ">=0.27,<0.28"
65+
cwltool = "==3.1.20230425144158"
6666
deal = ">=4.24.0,<5.0.0"
6767
deepdiff = ">=5.8,<7.0"
6868
deepmerge = "==1.0.1"
@@ -97,7 +97,7 @@ requests = ">=2.23.0,<2.31.1"
9797
rich = ">=9.3.0,<13.4.0"
9898
shellingham = "1.5.0.post1"
9999
tabulate = ">=0.7.7,<0.9.1"
100-
toil = "==5.7.1"
100+
toil = "==5.10.0"
101101
tqdm = "<4.62.4,>=4.48.1"
102102
werkzeug = ">=1.0.0,<2.2.4"
103103
yagup = ">=0.1.1"

renku/command/view_model/graph.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import io
2121
import json
2222
from enum import Enum
23-
from typing import Dict, List, Optional
23+
from typing import Dict, Iterator, List, Optional, cast
2424

2525
import pyld
2626
import rdflib
2727
from rdflib import ConjunctiveGraph, Graph
28+
from rdflib.query import ResultRow
2829
from rdflib.tools.rdf2dot import LABEL_PROPERTIES, NODECOLOR, rdf2dot
2930

3031

@@ -189,7 +190,7 @@ def color(p):
189190
}
190191
"""
191192

192-
for s, p, o in graph.query(sparql):
193+
for s, p, o in cast(Iterator[ResultRow], graph.query(sparql)):
193194
sn = node(s)
194195
if p == rdflib.RDFS.label:
195196
continue

renku/core/migration/m_0005__2_cwl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from urllib.parse import urlparse
2727

2828
from cwl_utils.parser import load_document_by_uri
29-
from cwl_utils.parser.cwl_v1_0 import CommandLineTool, InitialWorkDirRequirement
29+
from cwl_utils.parser.cwl_v1_0 import CommandLineTool, Directory, File, InitialWorkDirRequirement
3030
from werkzeug.utils import secure_filename
3131

3232
from renku.core.constant import RENKU_HOME
@@ -167,7 +167,7 @@ def _migrate_single_step(migration_context, cmd_line_tool, path, commit=None, pa
167167
matched_input = next(i for i in inputs if i.id.endswith(name))
168168
inputs.remove(matched_input)
169169

170-
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(matched_input.default["path"])
170+
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(matched_input.default.path)
171171
stdin = path.resolve().relative_to(project_context.path)
172172
id_ = CommandInput.generate_id(base_id, "stdin")
173173

@@ -237,7 +237,7 @@ def _migrate_single_step(migration_context, cmd_line_tool, path, commit=None, pa
237237
pass
238238

239239
if isinstance(matched_input.default, dict):
240-
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(matched_input.default["path"])
240+
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(matched_input.default.path)
241241
else:
242242
path = Path(matched_input.default)
243243

@@ -282,8 +282,8 @@ def _migrate_single_step(migration_context, cmd_line_tool, path, commit=None, pa
282282
if prefix and i.inputBinding.separate:
283283
prefix += " "
284284

285-
if isinstance(i.default, dict) and "class" in i.default and i.default["class"] in ["File", "Directory"]:
286-
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(i.default["path"])
285+
if isinstance(i.default, (File, Directory)):
286+
path = project_context.metadata_path / OLD_WORKFLOW_PATH / Path(str(i.default.path))
287287
path = Path(os.path.realpath(path)).relative_to(project_context.path)
288288

289289
run.inputs.append(

renku/core/workflow/converters/cwl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def workflow_convert(
148148
step_filename = Path(f"{uuid4()}.cwl")
149149
step_path = (tmpdir / step_filename).resolve()
150150
write_yaml(step_path, step.run.save())
151-
step.run = str(step_path)
151+
step.run = f"file://{step_path}"
152152
if filename is None:
153153
filename = Path(f"parent_{uuid4()}.cwl")
154154
else:

renku/data/pre-commit.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121

2222
# Find all modified or added files, and do nothing if there aren't any.
2323
export RENKU_DISABLE_VERSION_CHECK=true
24-
IFS=$'\n' read -r -d '' -a MODIFIED_FILES \
25-
<<< "$(git diff --name-only --cached --diff-filter=M)"
26-
IFS=$'\n' read -r -d '' -a ADDED_FILES \
27-
<<< "$(git diff --name-only --cached --diff-filter=A)"
24+
25+
declare -a MODIFIED_FILES=()
26+
while IFS= read -r -d '' file; do
27+
MODIFIED_FILES+=( "$file" )
28+
done < <(git diff -z --name-only --cached --diff-filter=M)
29+
30+
declare -a ADDED_FILES=()
31+
while IFS= read -r -d '' file; do
32+
ADDED_FILES+=( "$file" )
33+
done < <(git diff -z --name-only --cached --diff-filter=A)
34+
2835

2936
if [ ${#MODIFIED_FILES[@]} -ne 0 ] || [ ${#ADDED_FILES[@]} -ne 0 ]; then
3037
# Verify that renku is installed; if not, warn and exit.

renku/infrastructure/repository.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,10 @@ def get_existing_paths_in_revision(
917917
if files:
918918
# NOTE: check existing files
919919
for batch in split_paths(*files):
920-
existing_paths = git.Git(working_dir=self.path).ls_tree(*batch, r=revision, name_only=True)
921-
result.extend(existing_paths.splitlines())
920+
existing_paths = git.Git(working_dir=self.path).ls_tree(
921+
*batch, r=revision, name_only=True, z=True
922+
)
923+
result.extend(existing_paths.strip("\x00").split("\x00"))
922924

923925
if dirs:
924926
# NOTE: check existing dirs
@@ -930,7 +932,7 @@ def get_existing_paths_in_revision(
930932

931933
return result
932934
else:
933-
existing_files = git.Git().ls_tree(r=revision, name_only=True).splitlines()
935+
existing_files = git.Git().ls_tree(r=revision, name_only=True, z=True).strip("\x00").split("\x00")
934936
existing_dirs = git.Git().ls_tree(r=revision, name_only=True, d=True).splitlines()
935937
return existing_dirs + existing_files
936938
except git.GitCommandError as e:

tests/cli/test_workflow.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def _flatten_dict(obj, key_string=""):
711711

712712

713713
@pytest.mark.parametrize("provider", available_workflow_providers())
714-
def test_workflow_execute_command_with_api_parameter_set(runner, run_shell, project, capsys, transaction_id, provider):
714+
def test_workflow_execute_command_with_api_parameter_set(runner, run_shell, project, transaction_id, provider):
715715
"""Test executing a workflow with --set for a renku.ui.api.Parameter."""
716716
script = project.path / "script.py"
717717
output = project.path / "output"
@@ -740,7 +740,7 @@ def test_workflow_execute_command_with_api_parameter_set(runner, run_shell, proj
740740

741741

742742
@pytest.mark.parametrize("provider", available_workflow_providers())
743-
def test_workflow_execute_command_with_api_input_set(runner, run_shell, project, capsys, transaction_id, provider):
743+
def test_workflow_execute_command_with_api_input_set(runner, run_shell, project, transaction_id, provider):
744744
"""Test executing a workflow with --set for a renku.ui.api.Input."""
745745
script = project.path / "script.py"
746746
output = project.path / "output"
@@ -775,7 +775,7 @@ def test_workflow_execute_command_with_api_input_set(runner, run_shell, project,
775775

776776

777777
@pytest.mark.parametrize("provider", available_workflow_providers())
778-
def test_workflow_execute_command_with_api_output_set(runner, run_shell, project, capsys, transaction_id, provider):
778+
def test_workflow_execute_command_with_api_output_set(runner, run_shell, project, transaction_id, provider):
779779
"""Test executing a workflow with --set for a renku.ui.api.Output."""
780780
script = project.path / "script.py"
781781
output = project.path / "output"
@@ -806,7 +806,7 @@ def test_workflow_execute_command_with_api_output_set(runner, run_shell, project
806806
assert 0 == result.exit_code, format_result_exception(result)
807807

808808

809-
def test_workflow_execute_command_with_api_duplicate_output(runner, run_shell, project, capsys, transaction_id):
809+
def test_workflow_execute_command_with_api_duplicate_output(run_shell, project, transaction_id):
810810
"""Test executing a workflow with duplicate output with differing path."""
811811
script = project.path / "script.py"
812812
output = project.path / "output"
@@ -824,7 +824,7 @@ def test_workflow_execute_command_with_api_duplicate_output(runner, run_shell, p
824824
assert b"Error: Invalid parameter value - Duplicate input/output name found: my-output\n" in result[0]
825825

826826

827-
def test_workflow_execute_command_with_api_valid_duplicate_output(runner, run_shell, project, capsys, transaction_id):
827+
def test_workflow_execute_command_with_api_valid_duplicate_output(run_shell, project, transaction_id):
828828
"""Test executing a workflow with duplicate output with same path."""
829829
script = project.path / "script.py"
830830
output = project.path / "output"
@@ -844,7 +844,7 @@ def test_workflow_execute_command_with_api_valid_duplicate_output(runner, run_sh
844844
assert result[1] is None
845845

846846

847-
def test_workflow_execute_command_with_api_duplicate_input(runner, run_shell, project, capsys, transaction_id):
847+
def test_workflow_execute_command_with_api_duplicate_input(run_shell, project, transaction_id):
848848
"""Test executing a workflow with duplicate input with differing path."""
849849
script = project.path / "script.py"
850850
input = project.path / "input"
@@ -862,7 +862,7 @@ def test_workflow_execute_command_with_api_duplicate_input(runner, run_shell, pr
862862
assert b"Error: Invalid parameter value - Duplicate input/output name found: my-input\n" in result[0]
863863

864864

865-
def test_workflow_execute_command_with_api_valid_duplicate_input(runner, run_shell, project, capsys, transaction_id):
865+
def test_workflow_execute_command_with_api_valid_duplicate_input(run_shell, project, transaction_id):
866866
"""Test executing a workflow with duplicate input with same path."""
867867
script = project.path / "script.py"
868868
input = project.path / "input"

0 commit comments

Comments
 (0)