Skip to content

Commit 72ad1d5

Browse files
authored
fix(core): fix rerun overwriting plan details with previous versions (#3172)
1 parent 9285fe0 commit 72ad1d5

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

renku/infrastructure/gateway/plan_gateway.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def get_all_plans(self) -> List[AbstractPlan]:
6666
def add(self, plan: AbstractPlan) -> None:
6767
"""Add a plan to the database."""
6868
database = project_context.database
69+
70+
if database["plans"].get(plan.id) is not None:
71+
return
72+
6973
database["plans"].add(plan)
7074

7175
if plan.derived_from is not None:

tests/cli/test_workflow.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,8 @@ def test_reverted_activity_status(runner, project, with_injection):
13851385
write_and_commit_file(project.repository, input, "content")
13861386
output = project.path / "output"
13871387

1388-
assert 0 == runner.invoke(cli, ["run", "cat", input], stdout=output).exit_code
1388+
result = runner.invoke(cli, ["run", "cat", input], stdout=output)
1389+
assert 0 == result.exit_code, format_result_exception(result)
13891390
write_and_commit_file(project.repository, input, "changes")
13901391

13911392
with with_injection():
@@ -1409,3 +1410,33 @@ def test_reverted_activity_status(runner, project, with_injection):
14091410
assert activity_id not in runner.invoke(cli, ["log"]).output
14101411
assert "input" not in runner.invoke(cli, ["workflow", "inputs"]).output
14111412
assert "output" not in runner.invoke(cli, ["workflow", "outputs"]).output
1413+
1414+
1415+
def test_rerun_doesnt_update_plan_index(runner, project, with_injection):
1416+
"""Test that a rerun does not update the plan index."""
1417+
input = project.path / "input"
1418+
write_and_commit_file(project.repository, input, "content")
1419+
output = project.path / "output"
1420+
1421+
original_description = "1111111111111111"
1422+
result = runner.invoke(
1423+
cli, ["run", "--name", "my-workflow", "--description", original_description, "cat", input], stdout=output
1424+
)
1425+
assert 0 == result.exit_code, format_result_exception(result)
1426+
1427+
new_description = "22222222222222222"
1428+
result = runner.invoke(cli, ["workflow", "edit", "my-workflow", "--description", new_description])
1429+
assert 0 == result.exit_code, format_result_exception(result)
1430+
1431+
result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
1432+
assert 0 == result.exit_code, format_result_exception(result)
1433+
assert new_description in result.output
1434+
assert original_description not in result.output
1435+
1436+
result = runner.invoke(cli, ["rerun", output])
1437+
assert 0 == result.exit_code, format_result_exception(result)
1438+
1439+
result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
1440+
assert 0 == result.exit_code, format_result_exception(result)
1441+
assert new_description in result.output
1442+
assert original_description not in result.output

tests/core/test_plan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_plan_delete_errors(project_with_injection):
131131

132132
def test_plan_get_initial_id(project_with_injection):
133133
"""Test getting initial id of a plan."""
134-
grand_parent, parent, plan, child, grand_child, unrelated = create_dummy_plans()
134+
grand_parent, parent, plan, child, grand_child, _ = create_dummy_plans()
135135

136136
initial_id = get_initial_id(plan)
137137

@@ -143,7 +143,7 @@ def test_plan_get_initial_id(project_with_injection):
143143

144144
def test_get_activities(project_with_injection):
145145
"""Test getting activities of a plan."""
146-
grand_parent, parent, plan, child, grand_child, unrelated = create_dummy_plans()
146+
grand_parent, _, plan, child, grand_child, unrelated = create_dummy_plans()
147147
activities = [
148148
create_dummy_activity(plan),
149149
create_dummy_activity(grand_parent),

0 commit comments

Comments
 (0)