Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix rerun overwriting plan details with previous versions #3172

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions renku/infrastructure/gateway/plan_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def get_all_plans(self) -> List[AbstractPlan]:
def add(self, plan: AbstractPlan) -> None:
"""Add a plan to the database."""
database = project_context.database

if database["plans"].get(plan.id) is not None:
return

database["plans"].add(plan)

if plan.derived_from is not None:
Expand Down
33 changes: 32 additions & 1 deletion tests/cli/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ def test_reverted_activity_status(runner, project, with_injection):
write_and_commit_file(project.repository, input, "content")
output = project.path / "output"

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

with with_injection():
Expand All @@ -1409,3 +1410,33 @@ def test_reverted_activity_status(runner, project, with_injection):
assert activity_id not in runner.invoke(cli, ["log"]).output
assert "input" not in runner.invoke(cli, ["workflow", "inputs"]).output
assert "output" not in runner.invoke(cli, ["workflow", "outputs"]).output


def test_rerun_doesnt_update_plan_index(runner, project, with_injection):
"""Test that a rerun does not update the plan index."""
input = project.path / "input"
write_and_commit_file(project.repository, input, "content")
output = project.path / "output"

original_description = "1111111111111111"
result = runner.invoke(
cli, ["run", "--name", "my-workflow", "--description", original_description, "cat", input], stdout=output
)
assert 0 == result.exit_code, format_result_exception(result)

new_description = "22222222222222222"
result = runner.invoke(cli, ["workflow", "edit", "my-workflow", "--description", new_description])
assert 0 == result.exit_code, format_result_exception(result)

result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
assert 0 == result.exit_code, format_result_exception(result)
assert new_description in result.output
assert original_description not in result.output

result = runner.invoke(cli, ["rerun", output])
assert 0 == result.exit_code, format_result_exception(result)

result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
assert 0 == result.exit_code, format_result_exception(result)
assert new_description in result.output
assert original_description not in result.output
4 changes: 2 additions & 2 deletions tests/core/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_plan_delete_errors(project_with_injection):

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

initial_id = get_initial_id(plan)

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

def test_get_activities(project_with_injection):
"""Test getting activities of a plan."""
grand_parent, parent, plan, child, grand_child, unrelated = create_dummy_plans()
grand_parent, _, plan, child, grand_child, unrelated = create_dummy_plans()
activities = [
create_dummy_activity(plan),
create_dummy_activity(grand_parent),
Expand Down