Skip to content

Commit

Permalink
Add event serialization testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSava committed Dec 17, 2024
1 parent 0e19012 commit 261b703
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/everest/test_everserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from ropt.enums import OptimizerExitCode
from seba_sqlite.snapshot import SebaSnapshot

from _ert.events import event_from_json, event_to_json
from ert.run_models.everest_run_model import EverestRunModel
from everest.config import EverestConfig, ServerConfig
from everest.detached import ServerStatus, everserver_status
from everest.detached.jobs import everserver
Expand Down Expand Up @@ -271,3 +273,34 @@ def test_everserver_status_max_batch_num(
filter_out_gradient=False, batches=None
)
assert {data.batch for data in snapshot.simulation_data} == {0}


def test_event_serialization(
copy_math_func_test_data_to_tmp,
evaluator_server_config_generator,
):
config = EverestConfig.load_file("config_minimal.yml")

def check_status_round_tripping(status):
round_trip_status = json.loads(json.dumps(status))
assert round_trip_status == status

run_model = EverestRunModel.create(
config,
simulation_callback=check_status_round_tripping,
)

send_snapshot_event = run_model.send_snapshot_event

def check_event_serialization_round_trip(*args, **_):
event, iteration = args
event_json = event_to_json(event)
round_trip_event = event_from_json(str(event_json))
assert event == round_trip_event
send_snapshot_event(*args)

run_model.send_snapshot_event = check_event_serialization_round_trip

evaluator_server_config = evaluator_server_config_generator(run_model)

run_model.run_experiment(evaluator_server_config)

0 comments on commit 261b703

Please sign in to comment.