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

Click-navigation to future steps #515

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion protzilla/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ def extend(self, messages):
def clear(self):
self.messages = []

@property
def empty(self) -> bool:
return len(self.messages) == 0


class Plots:
def __init__(self, plots: list | None = None):
Expand Down Expand Up @@ -621,10 +625,22 @@ def goto_step(self, step_index: int, section: str) -> None:

step = self.all_steps_in_section(section)[step_index]
new_step_index = self.all_steps.index(step)

if new_step_index == self.current_step_index:
return
assert new_step_index < len(self.all_steps)

if new_step_index < self.current_step_index:
self.current_step_index = new_step_index
elif (
not step.output.is_empty
or not self.all_steps[new_step_index - 1].output.is_empty
):
self.current_step_index = new_step_index
else:
raise ValueError("Cannot go to a step that is after the current step")
raise ValueError(
f"Cannot go to a step that has no output yet: {step.display_name}. Please calculate the steps beforehand first."
)

def name_current_step_instance(self, new_instance_identifier: str) -> None:
"""
Expand Down
9 changes: 1 addition & 8 deletions tests/protzilla/test_run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from protzilla.methods.data_preprocessing import ImputationByMinPerProtein
from protzilla.methods.importing import MaxQuantImport

Expand Down Expand Up @@ -91,12 +89,7 @@ def test_step_goto(self, caplog, run_imported):
step = ImputationByMinPerProtein()
run_imported.step_add(step)
run_imported.step_goto(0, "data_preprocessing")
assert any(
message["level"] == logging.ERROR and "ValueError" in message["msg"]
for message in run_imported.current_messages
), "No error messages found in run.current_messages"
assert run_imported.current_step != step
run_imported.step_next()
assert run_imported.current_messages.empty
assert run_imported.current_step == step
run_imported.step_goto(0, "importing")
assert run_imported.current_step == run_imported.steps.all_steps[0]
Expand Down
Loading