From bff30e5a5a43549438c24d18f503345ee6c53eb9 Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Tue, 1 Oct 2024 15:12:14 +0200 Subject: [PATCH] Propagate data all the way --- src/_ert/events.py | 1 + src/ert/ensemble_evaluator/snapshot.py | 7 +++++++ src/ert/gui/model/node.py | 1 + src/ert/gui/model/snapshot.py | 2 ++ src/ert/gui/simulation/run_dialog.py | 13 ++++++++++++- src/ert/scheduler/job.py | 2 ++ src/ert/scheduler/scheduler.py | 4 +--- 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/_ert/events.py b/src/_ert/events.py index 0f810286f9e..06d8e4a98d3 100644 --- a/src/_ert/events.py +++ b/src/_ert/events.py @@ -109,6 +109,7 @@ class RealizationBaseEvent(BaseEvent): real: str ensemble: Union[str, None] = None queue_event_type: Union[str, None] = None + exec_hosts: Union[str, None] = None class RealizationPending(RealizationBaseEvent): diff --git a/src/ert/ensemble_evaluator/snapshot.py b/src/ert/ensemble_evaluator/snapshot.py index 00448fbd728..97bf4a84067 100644 --- a/src/ert/ensemble_evaluator/snapshot.py +++ b/src/ert/ensemble_evaluator/snapshot.py @@ -252,6 +252,7 @@ def update_realization( status: str, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, + exec_hosts: Optional[str] = None, callback_status_message: Optional[str] = None, ) -> "EnsembleSnapshot": self._realization_snapshots[real_id].update( @@ -260,6 +261,7 @@ def update_realization( status=status, start_time=start_time, end_time=end_time, + exec_hosts=exec_hosts, callback_status_message=callback_status_message, ) ) @@ -279,10 +281,12 @@ def update_from_event( status = _FM_TYPE_EVENT_TO_STATUS[type(event)] start_time = None end_time = None + exec_hosts = None callback_status_message = None if e_type is RealizationRunning: start_time = convert_iso8601_to_datetime(timestamp) + exec_hosts = event.exec_hosts elif e_type in { RealizationSuccess, RealizationFailed, @@ -296,6 +300,7 @@ def update_from_event( status, start_time, end_time, + exec_hosts, callback_status_message, ) @@ -395,6 +400,7 @@ class RealizationSnapshot(TypedDict, total=False): active: Optional[bool] start_time: Optional[datetime] end_time: Optional[datetime] + exec_hosts: Optional[str] fm_steps: Dict[str, FMStepSnapshot] callback_status_message: Optional[str] @@ -409,6 +415,7 @@ def _realization_dict_to_realization_snapshot( end_time=source.get("end_time"), callback_status_message=source.get("callback_status_message"), fm_steps=source.get("fm_steps", {}), + exec_hosts=source.get("exec_hosts"), ) return _filter_nones(realization) diff --git a/src/ert/gui/model/node.py b/src/ert/gui/model/node.py index 90a3772faff..29e294cf003 100644 --- a/src/ert/gui/model/node.py +++ b/src/ert/gui/model/node.py @@ -74,6 +74,7 @@ class RealNodeData: real_status_color: Optional[QColor] = None current_memory_usage: Optional[int] = None max_memory_usage: Optional[int] = None + exec_hosts: Optional[str] = None stderr: Optional[str] = None callback_status_message: Optional[str] = None diff --git a/src/ert/gui/model/snapshot.py b/src/ert/gui/model/snapshot.py index e5509888930..6ea4ba6e351 100644 --- a/src/ert/gui/model/snapshot.py +++ b/src/ert/gui/model/snapshot.py @@ -168,6 +168,8 @@ def _update_snapshot(self, snapshot: EnsembleSnapshot, iter_: str) -> None: data = real_node.data if real_status := real.get("status"): data.status = real_status + if real_exec_hosts := real.get("exec_hosts"): + data.exec_hosts = real_exec_hosts for real_fm_step_id, color in ( metadata["aggr_fm_step_status_colors"].get(real_id, {}).items() ): diff --git a/src/ert/gui/simulation/run_dialog.py b/src/ert/gui/simulation/run_dialog.py index df8f364f4be..6bf32884310 100644 --- a/src/ert/gui/simulation/run_dialog.py +++ b/src/ert/gui/simulation/run_dialog.py @@ -333,10 +333,21 @@ def on_snapshot_new_iteration( def _select_real(self, index: QModelIndex) -> None: real = index.row() iter_ = index.model().get_iter() # type: ignore + exec_hosts = None + + iter_node = self._snapshot_model.root.children.get(str(iter_), None) + if iter_node: + real_node = iter_node.children.get(str(real), None) + if real_node: + exec_hosts = real_node.data.exec_hosts + self._fm_step_overview.set_realization(iter_, real) - self._fm_step_label.setText( + text = ( f"Realization id {index.data(RealIens)} in iteration {index.data(IterNum)}" ) + if exec_hosts and exec_hosts != "-": + text += f", assigned to host: [{exec_hosts}]" + self._fm_step_label.setText(text) def closeEvent(self, a0: Optional[QCloseEvent]) -> None: if not self._notifier.is_simulation_running: diff --git a/src/ert/scheduler/job.py b/src/ert/scheduler/job.py index 831de54e85f..5a4316cf6f2 100644 --- a/src/ert/scheduler/job.py +++ b/src/ert/scheduler/job.py @@ -62,6 +62,7 @@ def __init__(self, scheduler: Scheduler, real: Realization) -> None: self.real = real self.state = JobState.WAITING self.started = asyncio.Event() + self.exec_hosts: str = "-" self.returncode: asyncio.Future[int] = asyncio.Future() self._aborted = False self._scheduler: Scheduler = scheduler @@ -263,6 +264,7 @@ async def _send(self, state: JobState) -> None: "event_type": _queue_jobstate_event_type[state], "queue_event_type": state, "real": str(self.iens), + "exec_hosts": self.exec_hosts, } self.state = state if state == JobState.FAILED: diff --git a/src/ert/scheduler/scheduler.py b/src/ert/scheduler/scheduler.py index a51f56e6d75..ed5fc816ccf 100644 --- a/src/ert/scheduler/scheduler.py +++ b/src/ert/scheduler/scheduler.py @@ -309,9 +309,7 @@ async def _process_event_queue(self) -> None: job.started.set() if isinstance(event, (StartedEvent, FinishedEvent)) and event.exec_hosts: - logger.info( - f"Realization {event.iens} was executed on host: {event.exec_hosts}" - ) + self._jobs[event.iens].exec_hosts = event.exec_hosts if ( isinstance(event, FinishedEvent)