Skip to content

Commit 101209c

Browse files
authored
fix(core): fix error when using external file in plan (#2815)
1 parent a0aa0bb commit 101209c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

renku/core/workflow/plan_factory.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ def add_outputs(self, candidates: Set[Tuple[Union[Path, str], Optional[str]]]):
285285
input_path = Path(os.path.abspath(path)).relative_to(self.working_dir)
286286
except FileNotFoundError:
287287
continue
288+
except ValueError:
289+
# NOTE: Raised if path is not relative to working_dir (external file)
290+
input_path = Path(parameter.default_value)
291+
292+
if not input_path.exists():
293+
continue
288294

289295
if input_path.is_dir() and tree.get(input_path):
290296
# The directory might exist before running the script

tests/cli/test_run.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
"""Test ``run`` command."""
1919

2020
import os
21+
from typing import cast
2122

2223
import pytest
2324

25+
from renku.domain_model.workflow.plan import Plan
2426
from renku.infrastructure.gateway.activity_gateway import ActivityGateway
2527
from renku.infrastructure.gateway.plan_gateway import PlanGateway
2628
from renku.ui.cli import cli
@@ -118,6 +120,31 @@ def test_run_metadata(renku_cli, runner, client, client_database_injection_manag
118120
assert 0 == result.exit_code, format_result_exception(result)
119121

120122

123+
def test_run_external_file(renku_cli, runner, client, client_database_injection_manager, tmpdir):
124+
"""Test run with workflow metadata."""
125+
126+
external_file = tmpdir.join("file_1")
127+
external_file.write(str(1))
128+
129+
exit_code, activity = renku_cli("run", "--name", "run-1", "cp", str(external_file), "file_1")
130+
131+
assert 0 == exit_code
132+
plan = activity.association.plan
133+
assert "run-1" == plan.name
134+
135+
with client_database_injection_manager(client):
136+
plan_gateway = PlanGateway()
137+
plan = cast(Plan, plan_gateway.get_by_id(plan.id))
138+
assert "run-1" == plan.name
139+
assert 1 == len(plan.parameters)
140+
assert 1 == len(plan.outputs)
141+
assert 0 == len(plan.inputs)
142+
assert plan.parameters[0].default_value == str(external_file)
143+
144+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
145+
assert 0 == result.exit_code, format_result_exception(result)
146+
147+
121148
@pytest.mark.parametrize(
122149
"command, name",
123150
[

0 commit comments

Comments
 (0)