This Draft PR includes some experimental work on a Composite API. This significantly upgrades Composite, transforming it from an intermediate class to the main simulation object. The main additions are to provide Composite a store hierarchy (Composite.store) and an engine instance (Composite.sim).
vivarium.experiments.composite_merge.test_store_composite demos some of this new API.
New features:
Composite's store can be accessed directly with Composite's __setitem__ and __getitem__ via the Store API: value = composite['path', 'to']
Composite.make_subcomposite(path) returns a new Composite object from a sub-branch at path -- this could potentially be just like EngineProcess from vivarium-ecoli.
Composite.generate_sim() initializes the simulation engine. This could alternatively be done automatically in the Composite constructor.
Composite.run_for(interval) runs the simulation.
Composite.get_data() returns the emitter data.
TODO ideas:
Composite could also have a tunnel_outer() method, which would automatically return all the outward-pointing ports -- this could be a lot like ports_schema. It might also need tunnel_inner() for the internal stores/ports that we may want to connect to.
Composite.set_parallel(path) would take the branch at the path, make a sub-composite, and run it in parallel. The top-level composite would look exactly the same -- this should be transparent.
By creating this pull request, I agree to the Contributor License
Agreement, which is available in CLA.md at the top level of this
repository.
DO NOT MERGE
This Draft PR includes some experimental work on a Composite API. This significantly upgrades
Composite
, transforming it from an intermediate class to the main simulation object. The main additions are to provide Composite a store hierarchy (Composite.store
) and an engine instance (Composite.sim
).vivarium.experiments.composite_merge.test_store_composite
demos some of this new API.New features:
__setitem__
and__getitem__
via the Store API:value = composite['path', 'to']
Composite.make_subcomposite(path)
returns a new Composite object from a sub-branch atpath
-- this could potentially be just like EngineProcess from vivarium-ecoli.Composite.generate_sim()
initializes the simulation engine. This could alternatively be done automatically in the Composite constructor.Composite.run_for(interval)
runs the simulation.Composite.get_data()
returns the emitter data.TODO ideas:
tunnel_outer()
method, which would automatically return all the outward-pointing ports -- this could be a lot likeports_schema
. It might also needtunnel_inner()
for the internal stores/ports that we may want to connect to.Composite.set_parallel(path)
would take the branch at the path, make a sub-composite, and run it in parallel. The top-level composite would look exactly the same -- this should be transparent.By creating this pull request, I agree to the Contributor License Agreement, which is available in
CLA.md
at the top level of this repository.