Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport step logging #9109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/_ert/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@


class Id:
FORWARD_MODEL_STEP_START_TYPE = Literal["forward_model_job.start"]
FORWARD_MODEL_STEP_RUNNING_TYPE = Literal["forward_model_job.running"]
FORWARD_MODEL_STEP_SUCCESS_TYPE = Literal["forward_model_job.success"]
FORWARD_MODEL_STEP_FAILURE_TYPE = Literal["forward_model_job.failure"]
FORWARD_MODEL_STEP_CHECKSUM_TYPE = Literal["forward_model_job.checksum"]
FORWARD_MODEL_STEP_START: Final = "forward_model_job.start"
FORWARD_MODEL_STEP_RUNNING: Final = "forward_model_job.running"
FORWARD_MODEL_STEP_SUCCESS: Final = "forward_model_job.success"
FORWARD_MODEL_STEP_FAILURE: Final = "forward_model_job.failure"
FORWARD_MODEL_STEP_CHECKSUM: Final = "forward_model_job.checksum"
FORWARD_MODEL_STEP_START_TYPE = Literal["forward_model_step.start"]
FORWARD_MODEL_STEP_RUNNING_TYPE = Literal["forward_model_step.running"]
FORWARD_MODEL_STEP_SUCCESS_TYPE = Literal["forward_model_step.success"]
FORWARD_MODEL_STEP_FAILURE_TYPE = Literal["forward_model_step.failure"]
FORWARD_MODEL_STEP_CHECKSUM_TYPE = Literal["forward_model_step.checksum"]
FORWARD_MODEL_STEP_START: Final = "forward_model_step.start"
FORWARD_MODEL_STEP_RUNNING: Final = "forward_model_step.running"
FORWARD_MODEL_STEP_SUCCESS: Final = "forward_model_step.success"
FORWARD_MODEL_STEP_FAILURE: Final = "forward_model_step.failure"
FORWARD_MODEL_STEP_CHECKSUM: Final = "forward_model_step.checksum"

REALIZATION_FAILURE_TYPE = Literal["realization.failure"]
REALIZATION_PENDING_TYPE = Literal["realization.pending"]
Expand Down
36 changes: 36 additions & 0 deletions src/ert/ensemble_evaluator/snapshot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import sys
import typing
from collections import defaultdict
Expand Down Expand Up @@ -46,6 +47,8 @@
from ert.ensemble_evaluator import identifiers as ids
from ert.ensemble_evaluator import state

logger = logging.getLogger(__name__)

if sys.version_info < (3, 11):
from backports.datetime_fromisoformat import MonkeyPatch # type: ignore

Expand Down Expand Up @@ -327,6 +330,39 @@ def update_from_event(
start_time = convert_iso8601_to_datetime(timestamp)
elif e_type in {ForwardModelStepSuccess, ForwardModelStepFailure}:
end_time = convert_iso8601_to_datetime(timestamp)

try:
start_time = self._fm_step_snapshots[event.real, event.fm_step].get(
"start_time"
)
cpu_seconds = self._fm_step_snapshots[
event.real, event.fm_step
].get("cpu_seconds")
fm_step_name = source_snapshot.reals[event.real]["fm_steps"][
event.fm_step
]["name"]
if start_time is not None:
logger.warning(
f"{event.event_type} {fm_step_name} "
f"walltime={(end_time - start_time).total_seconds()} "
f"cputime={cpu_seconds} "
f"ensemble={event.ensemble} "
f"step_index={event.fm_step} "
f"real={event.real}"
)
else:
logger.warning(
f"Should log fm_step runtime, but start_time was None, "
f"{event.event_type} {fm_step_name=} "
f"endtime={end_time.isoformat()} "
f"cputime={cpu_seconds} "
f"ensemble={event.ensemble} "
f"step_index={event.fm_step} "
f"real={event.real}"
)
except BaseException as e:
logger.warning(f"Should log fm_step runtime, but got exception {e}")

if type(event) is ForwardModelStepFailure:
error = event.error_msg if event.error_msg else ""
else:
Expand Down
Loading