How to Use a BioModule
This guide shows how to instantiate an existing module, inspect its typed ports, wire it into a world, and read back outputs or snapshots.
Import and instantiate
from your_biomodule_package.population import PopulationCounter
population = PopulationCounter(initial_count=100, growth_rate=0.05)Inspect ports
print(population.inputs())
print(population.outputs())Current-kernel modules should expose dict[str, SignalSpec] mappings, not sets of port names.
Wire into a world
import biosimulant as biosim
from your_biomodule_package.monitoring import PopulationMonitor
world = biosim.BioWorld(communication_step=1.0)
builder = biosim.WiringBuilder(world)
builder.add("population", population)
builder.add("monitor", PopulationMonitor())
builder.connect("population.population_state", ["monitor.population_state"])
builder.apply()Run and inspect outputs
world.run(duration=10.0)
outputs = population.get_outputs()
signal = outputs["population_state"]
print(signal.value)
print(signal.emitted_at)Signals are typed runtime objects such as ScalarSignal, ArraySignal, RecordSignal, or EventSignal.
Snapshots
snapshot = population.snapshot()
print(snapshot)Use snapshots for deterministic reruns and branching. Do not assume a kernel-level reset API exists.
Visualizations
visuals = world.collect_visuals()
for entry in visuals:
print(entry["module"], entry["visuals"])If you are working from a packaged model, the manifest’s io block should match the runtime ports returned by inputs() and outputs().