epymorph.event
epymorph's event framework.
epymorph components may define a set of events relevant to their function,
and during processing can publish to the singleton EventBus
for subscription
and processing by other systems.
OnStart
Bases: NamedTuple
Event payload for the start of a simulation.
OnTick
Bases: NamedTuple
Event payload for the completion of a simulation tick.
OnMovementStart
Bases: NamedTuple
Event payload for the start of movement processing during a tick.
OnMovementClause
Bases: NamedTuple
Event payload for the completion of processing a movement clause.
requested
instance-attribute
The number of individuals this clause 'wants' to move, that is, the values returned by its clause function. (An NxN array.)
actual
instance-attribute
The actual number of individuals moved, by source, destination, and compartment. (An NxNxC array.)
is_throttled
instance-attribute
is_throttled: bool
Did the clause request to move more people than were available (at any location)?
OnMovementFinish
Bases: NamedTuple
Event payload for the completion of movement processing during a tick.
DownloadActivity
Bases: NamedTuple
Part of the ADRIOProgress
event payload describing ADRIO network activity.
All fields are optional, as it may be possible to measure some but not others
depending on the data source. ADRIOs should avoid reporting empty activity
events and instead instead just report None
(see ADRIO
methods).
ADRIOProgress
Bases: NamedTuple
Event payload for ADRIO data processing progress.
Not all ADRIOs will be able to report progress meaningfully, but those that do
should emit one event when they start (with ratio_complete
== 0)
and one when they finish (with ratio_complete
== 1). They are free
to report as many intermediate progress events as they like.
ratio_complete
instance-attribute
ratio_complete: float
What ratio complete is it? (0: just started; 1: done)
download
instance-attribute
download: DownloadActivity | None
Download activity if any, and if it can be measured.
duration
instance-attribute
duration: float | None
If complete, how long did the ADRIO take overall (in seconds)?
EventBus
A singleton for epymorph event publishing and subscription.
Obtain a reference to the global event bus by constructing it as usual --
EventBus()
-- but be aware that this will produce the same instance every time.
on_start
instance-attribute
Event fires at the start of a simulation run.
on_tick
instance-attribute
Event fires after each tick has been processed.
on_finish
instance-attribute
Event fires after a simulation run is complete.
on_movement_start
instance-attribute
on_movement_start: Event[OnMovementStart] = Event()
Event fires at the start of the movement processing phase for every simulation tick.
on_movement_clause
instance-attribute
on_movement_clause: Event[OnMovementClause] = Event()
Event fires after processing each active movement clause.
on_movement_finish
instance-attribute
on_movement_finish: Event[OnMovementFinish] = Event()
Event fires at the end of the movement processing phase for every simulation tick.
on_adrio_progress
instance-attribute
on_adrio_progress: Event[ADRIOProgress] = Event()
Event fires when an ADRIO is fetching data.