From 535a6ae7ad002ba0dc7e4d51c72ae55673e1ecab Mon Sep 17 00:00:00 2001 From: PekkaSavolainen <43600314+PekkaSavolainen@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:00:54 +0300 Subject: [PATCH] Changes related to ditching Dagster (#2715) - Fix animations and item icons on Design View and headless mode - Update CHANGELOG Re Issue #2523 --- CHANGELOG.md | 1 + requirements.txt | 4 ++-- spinetoolbox/headless.py | 4 ++-- spinetoolbox/project_item/project_item.py | 2 +- spinetoolbox/spine_engine_worker.py | 5 +++-- tests/server/test_RemoteSpineEngineManager.py | 17 +++++++++-------- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a01fee99..b74906de0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Many parts of the Spine data structure have been redesigned. ### Removed - Project dock widget +- Dependency on Dagster ### Fixed diff --git a/requirements.txt b/requirements.txt index 711d9ec77..60dff67f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -e git+https://github.com/spine-tools/Spine-Database-API.git@0.8-dev#egg=spinedb_api --e git+https://github.com/spine-tools/spine-engine.git@0.8-dev#egg=spine_engine --e git+https://github.com/spine-tools/spine-items.git@0.8-dev#egg=spine_items +-e git+https://github.com/spine-tools/spine-engine.git@jumpster#egg=spine_engine +-e git+https://github.com/spine-tools/spine-items.git@issue_2523#egg=spine_items -e . diff --git a/spinetoolbox/headless.py b/spinetoolbox/headless.py index 70f175e3a..1147b6375 100644 --- a/spinetoolbox/headless.py +++ b/spinetoolbox/headless.py @@ -23,7 +23,7 @@ from spine_engine.exception import EngineInitFailed from spine_engine.load_project_items import load_item_specification_factories from spine_engine.utils.serialization import deserialize_path -from spine_engine.utils.helpers import get_file_size +from spine_engine.utils.helpers import get_file_size, ExecutionDirection from spine_engine.server.util.zip_handler import ZipHandler from .server.engine_client import EngineClient, RemoteEngineInitFailed, ClientSecurityModel from .project_item.logging_connection import HeadlessConnection @@ -424,7 +424,7 @@ def _handle_node_execution_started(self, data): Args: data (dict): execution start data """ - if data["direction"] == "BACKWARD": + if data["direction"] == ExecutionDirection.BACKWARD: # Currently there are no interesting messages when executing backwards. return self._node_messages[data["item_name"]] = dict() diff --git a/spinetoolbox/project_item/project_item.py b/spinetoolbox/project_item/project_item.py index c7b88115f..4588449ed 100644 --- a/spinetoolbox/project_item/project_item.py +++ b/spinetoolbox/project_item/project_item.py @@ -221,7 +221,7 @@ def handle_execution_successful(self, execution_direction, engine_state): """Performs item dependent actions after the execution item has finished successfully. Args: - execution_direction (str): "FORWARD" or "BACKWARD" + execution_direction (ExecutionDirection): ExecutionDirection.FORWARD or ExecutionDirection.BACKWARD engine_state: engine state after item's execution """ diff --git a/spinetoolbox/spine_engine_worker.py b/spinetoolbox/spine_engine_worker.py index 3d9e328e1..31f4bcdad 100644 --- a/spinetoolbox/spine_engine_worker.py +++ b/spinetoolbox/spine_engine_worker.py @@ -15,6 +15,7 @@ from PySide6.QtCore import Signal, Slot, QObject, QThread from spine_engine.exception import EngineInitFailed, RemoteEngineInitFailed from spine_engine.spine_engine import ItemExecutionFinishState, SpineEngineState +from spine_engine.utils.helpers import ExecutionDirection from .widgets.options_dialog import OptionsDialog from .spine_engine_manager import make_engine_manager, LocalSpineEngineManager @@ -34,7 +35,7 @@ def _handle_node_execution_ignored(project_items): @Slot(object, object) def _handle_node_execution_started(item, direction): icon = item.get_icon() - if direction == "FORWARD": + if direction == ExecutionDirection.FORWARD: icon.execution_icon.mark_execution_started() if hasattr(icon, "animation_signaller"): icon.animation_signaller.animation_started.emit() @@ -43,7 +44,7 @@ def _handle_node_execution_started(item, direction): @Slot(object, object, object, object) def _handle_node_execution_finished(item, direction, item_state): icon = item.get_icon() - if direction == "FORWARD": + if direction == ExecutionDirection.FORWARD: icon.execution_icon.mark_execution_finished(item_state) if hasattr(icon, "animation_signaller"): icon.animation_signaller.animation_stopped.emit() diff --git a/tests/server/test_RemoteSpineEngineManager.py b/tests/server/test_RemoteSpineEngineManager.py index 3adfb53ec..7c7724359 100644 --- a/tests/server/test_RemoteSpineEngineManager.py +++ b/tests/server/test_RemoteSpineEngineManager.py @@ -16,6 +16,7 @@ from spinetoolbox.spine_engine_manager import RemoteSpineEngineManager from spine_engine import ItemExecutionFinishState from spine_engine.server.util.event_data_converter import EventDataConverter +from spine_engine.utils.helpers import ExecutionDirection class TestRemoteSpineEngineManager(unittest.TestCase): @@ -62,17 +63,17 @@ def yield_events_dag_succeeds(): # Convert some events fresh from SpineEngine first into # (bytes) json strings to simulate events that arrive to EngineClient engine_events = [ - ("exec_started", {"item_name": "Data Connection 1", "direction": "BACKWARD"}), + ("exec_started", {"item_name": "Data Connection 1", "direction": ExecutionDirection.BACKWARD}), ( "exec_finished", { "item_name": "Data Connection 1", - "direction": "BACKWARD", + "direction": ExecutionDirection.BACKWARD, "state": "RUNNING", "item_state": ItemExecutionFinishState.SUCCESS, }, ), - ("exec_started", {"item_name": "Data Connection 1", "direction": "FORWARD"}), + ("exec_started", {"item_name": "Data Connection 1", "direction": ExecutionDirection.FORWARD}), ( "event_msg", { @@ -86,7 +87,7 @@ def yield_events_dag_succeeds(): "exec_finished", { "item_name": "Data Connection 1", - "direction": "FORWARD", + "direction": ExecutionDirection.FORWARD, "state": "RUNNING", "item_state": ItemExecutionFinishState.SUCCESS, }, @@ -104,17 +105,17 @@ def yield_events_dag_succeeds(): def yield_events_dag_fails(): """Received event generator. Yields events that look like they were PULLed from server.""" engine_events = [ - ("exec_started", {"item_name": "Data Connection 1", "direction": "BACKWARD"}), + ("exec_started", {"item_name": "Data Connection 1", "direction": ExecutionDirection.BACKWARD}), ( "exec_finished", { "item_name": "Data Connection 1", - "direction": "BACKWARD", + "direction": ExecutionDirection.BACKWARD, "state": "RUNNING", "item_state": ItemExecutionFinishState.FAILURE, }, ), - ("exec_started", {"item_name": "Data Connection 1", "direction": "FORWARD"}), + ("exec_started", {"item_name": "Data Connection 1", "direction": ExecutionDirection.FORWARD}), ( "event_msg", { @@ -128,7 +129,7 @@ def yield_events_dag_fails(): "exec_finished", { "item_name": "Data Connection 1", - "direction": "FORWARD", + "direction": ExecutionDirection.FORWARD, "state": "RUNNING", "item_state": ItemExecutionFinishState.FAILURE, },