<jupyter_start><jupyter_text>Saving a toy engineFirst save the PES. Then save the whole engine. Make sure that the PES objects only show up once!<jupyter_code>pes = (
    toys.OuterWalls([1.0, 1.0], [0.0, 0.0]) +
    toys.Gaussian(-0.7, [12.0, 12.0], [0.0, 0.4]) +
    toys.Gaussian(-0.7, [12.0, 12.0], [-0.5, -0.5]) +
    toys.Gaussian(-0.7, [12.0, 12.0], [0.5, -0.5])
)
storage.save(pes)

with backend.engine.connect() as conn:
    uuids = conn.execute(backend.metadata.tables['uuid'].select())
    sim_obj = conn.execute(backend.metadata.tables['simulation_objects'].select())
    
print(list(uuids))
    
for obj in sim_obj:
    print(obj)
topology=toys.Topology(
    n_spatial = 2,
    masses =[1.0, 1.0],
    pes = pes
)
integ = toys.LangevinBAOABIntegrator(dt=0.02, temperature=0.1, gamma=2.5)

options={
    'integ' : integ,
    'n_frames_max' : 5000,
    'n_steps_per_frame' : 1
}

engine = toys.Engine(
    options=options,
    topology=topology
)
storage.save(engine)
with backend.engine.connect() as conn:
    sim_obj = conn.execute(backend.metadata.tables['simulation_objects'].select())
        
for obj in sim_obj:
    print(obj)<jupyter_output>(1, '48956517759891307508157719614706417678', '{"pes1": "UUID(48956517759891307508157719614706417674)", "pes2": "UUID(48956517759891307508157719614706417676)", "__module__": "openpathsampling.engines.toy.pes", "__class__": "PES_Add"}', None)
(2, '48956517759891307508157719614706417674', '{"pes1": "UUID(48956517759891307508157719614706417670)", "pes2": "UUID(48956517759891307508157719614706417672)", "__module__": "openpathsampling.engines.toy.pes", "__class__": "PES_Add"}', None)
(3, '48956517759891307508157719614706417676', '{"A": -0.7, "alpha": [12.0, 12.0], "x0": [0.5, -0.5], "__module__": "openpathsampling.engines.toy.pes", "__class__": "Gaussian"}', None)
(4, '48956517759891307508157719614706417670', '{"pes1": "UUID(48956517759891307508157719614706417666)", "pes2": "UUID(48956517759891307508157719614706417668)", "__module__": "openpathsampling.engines.toy.pes", "__class__": "PES_Add"}', None)
(5, '48956517759891307508157719614706417672', '{"A": -0.7, "alpha": [12.0, 12.0], "x0": [-[...]<jupyter_text>Storing a snapshotSnapshots need to separately register with storage. Here we'll do that manually.<jupyter_code>template = toys.Snapshot(
    coordinates=np.array([[-0.5, -0.5]]), 
    velocities=np.array([[0.0,0.0]]),
    engine=engine
)
# this needs to be built by the snapshot itself, based on the engine descriptor
snapshot_schema = {'snapshot0': [('coordinates', 'ndarray.float64(1,2)'), ('velocities', 'ndarray.float64(1,2)'),
                                 ('engine', 'uuid')]}
snapshot_class_info = ClassInfo(table='snapshot0', cls=toys.ToySnapshot, serializer=None, deserializer=None)

storage.register_schema(snapshot_schema, [snapshot_class_info])
storage.class_info
storage.save(template)<jupyter_output><empty_output><jupyter_text>Storing a fresh snapshot/engineThe previous only added the snapshot to the store, because the engine had been loaded above.<jupyter_code>new_engine = toys.Engine(
    options=options,
    topology=topology
)

new_snapshot = toys.Snapshot(
    coordinates=np.array([[-0.5, -0.5]]), 
    velocities=np.array([[0.0,0.0]]),
    engine=new_engine
)

# note that topology/PES is still the same, so should not store
storage.save(new_snapshot)<jupyter_output><empty_output><jupyter_text>Registering snapshot class from the features<jupyter_code>from openpathsampling.experimental.storage.snapshots import schema_from_entries, schema_for_snapshot, snapshot_registration_info
new_snapshot.engine.descriptor
new_snapshot.__features__.lazy
schema_from_entries(new_snapshot.__features__.classes, new_snapshot.__features__.lazy)
schema_for_snapshot(new_snapshot)
snapshot_registration_info(new_snapshot, 0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15388614504808942, 'fraction_numerical': 0.1401091759812841, 'mean_word_length': 5.786596119929453, 'pattern_counts': {'":': 20, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '206127', 'license': 'MIT', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1461, 'n_words': 252, 'path': 'tests/03_toy_storage.ipynb', 'repo_name': 'dwhswenson/ops-storage-notebooks', 'size': '3847'}