Skip to content

Commit

Permalink
Add custom event for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Jan 21, 2025
1 parent 9fc534f commit 7de304a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -94,6 +102,7 @@
| RunModelUpdateBeginEvent
| RunModelDataEvent
| RunModelUpdateEndEvent
| CustomEvent
)


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7de304a

Please sign in to comment.