From d54e684cc2e7a9898cad3373c2a1021eb184f15d Mon Sep 17 00:00:00 2001 From: henning Date: Fri, 21 Jun 2024 14:32:42 +0200 Subject: [PATCH 1/3] Add hidden workflows for test --- protzilla/steps.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protzilla/steps.py b/protzilla/steps.py index ad898d9e..b6ff9ef8 100644 --- a/protzilla/steps.py +++ b/protzilla/steps.py @@ -623,8 +623,12 @@ def goto_step(self, step_index: int, section: str) -> None: new_step_index = self.all_steps.index(step) if new_step_index < self.current_step_index: self.current_step_index = new_step_index + elif new_step_index < len(self.all_steps) and not step.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: """ From 6231eb6ece7a1baad6143be545134dd3b793e23b Mon Sep 17 00:00:00 2001 From: henning Date: Fri, 21 Jun 2024 14:41:55 +0200 Subject: [PATCH 2/3] Make step_goto more robust --- protzilla/steps.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/protzilla/steps.py b/protzilla/steps.py index b6ff9ef8..0371d380 100644 --- a/protzilla/steps.py +++ b/protzilla/steps.py @@ -621,9 +621,17 @@ 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 new_step_index < len(self.all_steps) and not step.output.is_empty: + 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( From c1941e432feca96f71625d6379489f40b9272c6e Mon Sep 17 00:00:00 2001 From: henning Date: Tue, 25 Jun 2024 11:12:28 +0200 Subject: [PATCH 3/3] Fix test, add empty property to Messages --- protzilla/steps.py | 4 ++++ tests/protzilla/test_run.py | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/protzilla/steps.py b/protzilla/steps.py index 0371d380..3326acdb 100644 --- a/protzilla/steps.py +++ b/protzilla/steps.py @@ -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): diff --git a/tests/protzilla/test_run.py b/tests/protzilla/test_run.py index fd6276cc..7536c9e9 100644 --- a/tests/protzilla/test_run.py +++ b/tests/protzilla/test_run.py @@ -1,5 +1,3 @@ -import logging - from protzilla.methods.data_preprocessing import ImputationByMinPerProtein from protzilla.methods.importing import MaxQuantImport @@ -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]