Skip to content

Commit

Permalink
Rem getNum* functions while poking queue directly
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Nov 20, 2023
1 parent 4d3c5fe commit 111f575
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
13 changes: 8 additions & 5 deletions src/ert/simulator/batch_simulator_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import numpy as np

from ert.realization_state import RealizationState

from .simulation_context import SimulationContext

if TYPE_CHECKING:
Expand Down Expand Up @@ -53,11 +55,11 @@ def status(self) -> Status:
Will return the state of the simulations.
"""
return Status(
running=self.getNumRunning(),
waiting=self.getNumWaiting(),
pending=self.getNumPending(),
complete=self.getNumSuccess(),
failed=self.getNumFailed(),
running=self._job_queue.count_status(RealizationState.RUNNING),
waiting=self._job_queue.count_status(RealizationState.WAITING),
pending=self._job_queue.count_status(RealizationState.PENDING),
complete=self._job_queue.count_status(RealizationState.SUCCESS),
failed=self._job_queue.count_status(RealizationState.FAILED),
)

def results(self) -> List[Optional[Dict[str, "npt.NDArray[np.float64]"]]]:
Expand Down Expand Up @@ -107,3 +109,4 @@ def results(self) -> List[Optional[Dict[str, "npt.NDArray[np.float64]"]]]:
res.append(d)

return res
return res
23 changes: 4 additions & 19 deletions src/ert/simulator/simulation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,6 @@ def isRunning(self) -> bool:
# TODO: Should separate between running jobs and having loaded all data
return self._sim_thread.is_alive() or self._job_queue.is_active()

def getNumPending(self) -> int:
return self._job_queue.count_status(RealizationState.PENDING) # type: ignore

def getNumRunning(self) -> int:
return self._job_queue.count_status(RealizationState.RUNNING) # type: ignore

def getNumSuccess(self) -> int:
return self._job_queue.count_status(RealizationState.SUCCESS) # type: ignore

def getNumFailed(self) -> int:
return self._job_queue.count_status(RealizationState.FAILED) # type: ignore

def getNumWaiting(self) -> int:
return self._job_queue.count_status(RealizationState.WAITING) # type: ignore

def didRealizationSucceed(self, iens: int) -> bool:
queue_index = self.get_run_args(iens).queue_index
if queue_index is None:
Expand All @@ -193,10 +178,10 @@ def isRealizationFinished(self, iens: int) -> bool:

def __repr__(self) -> str:
running = "running" if self.isRunning() else "not running"
numRunn = self.getNumRunning()
numSucc = self.getNumSuccess()
numFail = self.getNumFailed()
numWait = self.getNumWaiting()
numRunn = self._job_queue.count_status(RealizationState.RUNNING)
numSucc = self._job_queue.count_status(RealizationState.SUCCESS)
numFail = self._job_queue.count_status(RealizationState.FAILED)
numWait = self._job_queue.count_status(RealizationState.WAITING)
return (
f"SimulationContext({running}, #running = {numRunn}, "
f"#success = {numSucc}, #failed = {numFail}, #waiting = {numWait})"
Expand Down

0 comments on commit 111f575

Please sign in to comment.