campaign
Simple campaign builder for EMOD simulations.
Import this module, add valid campaign events via add, and write the
campaign file with save.
add(event, note=None)
Add a complete campaign event to the campaign builder.
The event is assumed to be valid and is not validated here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
A complete campaign event object. It must support
|
required | |
note
|
str
|
An optional human-readable note added to the event
inside the output |
None
|
Source code in emod_api/campaign.py
get_recv_trigger(trigger, old=use_old_adhoc_handling)
Register an individual-level event as listened to.
Tracks which individual events are used throughout the simulation
so that validate_custom_individual_events can validate that every
listened-to event has a corresponding broadcast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger
|
The individual event name string. |
required | |
old
|
Unused. Kept for backwards compatibility. |
use_old_adhoc_handling
|
Returns:
| Type | Description |
|---|---|
|
The event name, unchanged. |
Source code in emod_api/campaign.py
get_schema()
Return the loaded schema JSON dictionary.
Returns:
| Type | Description |
|---|---|
|
The parsed schema dictionary, or |
|
|
not been called. |
get_send_trigger(trigger, old=use_old_adhoc_handling)
Register an individual-level event as broadcast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger
|
The individual event name string. |
required | |
old
|
Unused. Kept for backwards compatibility. |
use_old_adhoc_handling
|
Returns:
| Type | Description |
|---|---|
|
The event name, unchanged. |
Source code in emod_api/campaign.py
reset()
Reset all campaign state to defaults.
Clears accumulated events, signal tracking lists, event mappings, and the schema cache.
Source code in emod_api/campaign.py
save(filename='campaign.json')
Save the accumulated campaign events to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output file path. |
'campaign.json'
|
Returns:
| Type | Description |
|---|---|
|
The filename that was written. |
Source code in emod_api/campaign.py
set_broadcast_coordinator_event(event)
Register a coordinator-level event as broadcast.
Tracks which coordinator events are used throughout the simulation
so that validate_custom_coordinator_events can validate that every
broadcast event has something listening to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
str
|
The coordinator event name string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The event name, unchanged. |
Source code in emod_api/campaign.py
set_broadcast_node_event(event)
Register a node-level event as broadcast.
Tracks which node events are used throughout the simulation so
that validate_custom_node_events can validate that every broadcast
event has something listening to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
str
|
The node event name string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The event name, unchanged. |
Source code in emod_api/campaign.py
set_listened_coordinator_event(event)
Register a coordinator-level event as listened to.
Tracks which coordinator events are used throughout the simulation
so that validate_custom_coordinator_events can validate that every
listened-to event has a corresponding broadcast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
str
|
The coordinator event name string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The event name, unchanged. |
Source code in emod_api/campaign.py
set_listened_node_event(event)
Register a node-level event as listened to.
Tracks which node events are used throughout the simulation so
that validate_custom_node_events can validate that every listened-to
event has a corresponding broadcast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
str
|
The node event name string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The event name, unchanged. |
Source code in emod_api/campaign.py
set_schema(schema_path_in)
Set the schema file path and reset all campaign state.
This is essentially the "start building a campaign" entry point.
It clears any previously accumulated events and loads the new schema.
Also extracts built-in event lists for individual, node, and
coordinator levels by recursively searching for
ReportEventRecorder, ReportEventRecorderNode, and
ReportEventRecorderCoordinator in the schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_path_in
|
Path to a |
required |
Source code in emod_api/campaign.py
validate_custom_coordinator_events()
Validate and return deduplicated custom coordinator-level events.
Returns:
| Type | Description |
|---|---|
|
A list of unique coordinator event name strings that are broadcast |
|
|
in the campaign. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any coordinator events are listened to but never broadcast. |
Source code in emod_api/campaign.py
validate_custom_individual_events()
Validate and return deduplicated custom individual-level events.
Returns:
| Type | Description |
|---|---|
|
A list of unique individual event name strings that are broadcast |
|
|
in the campaign. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any individual events are listened to but never broadcast. |
Source code in emod_api/campaign.py
validate_custom_node_events()
Validate and return deduplicated custom node-level events.
Returns:
| Type | Description |
|---|---|
|
A list of unique node event name strings that are broadcast |
|
|
in the campaign. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any node events are listened to but never broadcast. |