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

Add event serialization testing #9573

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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, _ = args
event_json = event_to_json(event)
round_trip_event = event_from_json(str(event_json))
assert event == round_trip_event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, if we get a FullSnapshotEvent or a SnapshotUpdateEvent, are we able to differentiate them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

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)
Loading