Skip to content
Open
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
10 changes: 10 additions & 0 deletions ecoli/experiments/ecoli_engine_process.py
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Serialize metadata using default serializer.

Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def run_simulation(config):
metadata.pop("initial_state", None)
metadata["git_hash"] = get_git_revision_hash()
metadata["git_diff"] = get_git_diff()
metadata = serialize_value(metadata)

# Since unique numpy updater is an class method, internal
# deepcopying in vivarium-core causes this warning to appear
Expand All @@ -467,11 +468,20 @@ def run_simulation(config):
topology=composite.topology,
initial_state=initial_state,
experiment_id=experiment_id,
emit_config=config.get("emit_config", False),
Comment thread
thalassemia marked this conversation as resolved.
emitter=emitter_config,
progress_bar=config["progress_bar"],
metadata=metadata,
profile=config["profile"],
initial_global_time=config.get("start_time", 0.0),
emit_topology=config.get("emit_topology", True),
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added missing options with respect to vivarium-core Engine class. Default values also imported from Engine class initiation.

emit_processes=config.get("emit_processes", False),
emit_step=config.get("emit_step", 1),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting, I did not know that the emit_step was configurable. Thanks for filling these in!

display_info=config.get("display_info", True),
global_time_precision=config.get("global_time_precision", None),
store_schema=config.get("store_schema", None),
description=config.get("description", ""),
experiment_name=config.get("experiment_name", None),
)
# Unnecessary reference to initial_state
engine.initial_state = None
Expand Down
8 changes: 6 additions & 2 deletions ecoli/library/serialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import orjson
import re
import ast
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Just moved it as requested.

from unum import Unum
from vivarium.core.registry import Serializer
from vivarium.library.topology import convert_path_style, normalize_path
Expand Down Expand Up @@ -80,9 +81,12 @@ def deserialize(self, data):
matched_regex = self.regex_for_serialized.fullmatch(data)
if matched_regex:
data = matched_regex.group(1)
data = orjson.loads(data)
if data.startswith("("):
data = ast.literal_eval(data)
else:
data = orjson.loads(data)
rng = np.random.RandomState()
rng.set_state(data)
rng.set_state(tuple(data))
return rng


Expand Down
Loading