From 7de304a1153e048251dec9136990173153da4c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Tue, 21 Jan 2025 15:18:08 +0100 Subject: [PATCH] Add custom event for testing --- src/ert/run_models/base_run_model.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index f4fd22c9844..e2135930ff6 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -12,9 +12,10 @@ from collections import defaultdict from collections.abc import Generator, MutableSequence from contextlib import contextmanager +from dataclasses import dataclass from pathlib import Path from queue import SimpleQueue -from typing import TYPE_CHECKING, Any, cast +from typing import TYPE_CHECKING, Any, cast, Literal import numpy as np @@ -81,6 +82,13 @@ if TYPE_CHECKING: from ert.config import QueueConfig + +@dataclass +class CustomEvent: + msg: str + event_type: Literal["CustomEvent"] = "CustomEvent" + + StatusEvents = ( FullSnapshotEvent | SnapshotUpdateEvent @@ -94,6 +102,7 @@ | RunModelUpdateBeginEvent | RunModelDataEvent | RunModelUpdateEndEvent + | CustomEvent ) @@ -237,7 +246,10 @@ def group(cls) -> str | None: return None def send_event(self, event: StatusEvents) -> None: - self._status_queue.put(event) + if isinstance(event, EndEvent): + self._status_queue.put(event) + else: + self._status_queue.put(CustomEvent(msg="Hello world")) def send_smoother_event( self, iteration: int, run_id: uuid.UUID, event: AnalysisEvent