gnome.multi_model_broadcast¶
Classes¶
This is a consumer process that makes the model available |
|
Here is where we spawn an array of model consumer processes |
Module Contents¶
- class gnome.multi_model_broadcast.ModelConsumer(task_port, model, ipc_folder='.')¶
Bases:
multiprocessing.Process
This is a consumer process that makes the model available upon process creation so that registered commands can act upon the model.
Program flow:
Read a command from the task queue
if there is a None command, we exit the process.
Parse the data received in the format:
('registeredcommand', {arg1: val1, arg2: val2, ... }, )
Attempt to perform the registered command. Registered commands are defined as private methods of this class.
Returns the results in a results queue
- task_port¶
- model¶
- ipc_folder = '.'¶
- run()¶
Method to be run in sub-process; can be overridden in sub-class
- cleanup_inherited_files()¶
- handle_cmd(msg)¶
the IOLoop only uses recv_multipart(), so we will always get a list of byte strings.
- class gnome.multi_model_broadcast.ModelBroadcaster(model, wind_speed_uncertainties, spill_amount_uncertainties, ipc_folder='.')¶
Bases:
gnome.GnomeId
Here is where we spawn an array of model consumer processes based on the variations in the model configurations we would like.
More specifically, the model variations we are interested in are uncertainty variations.
- model¶
- ipc_folder = '.'¶
- context = None¶
- consumers = []¶
- tasks = []¶
- task_files = []¶
- lookup¶
- cmd(command, args, uncertainty_values=None, idx=None, in_parallel=True, timeout=None)¶
Broadcast a command to the subprocesses, or target a specific subprocess.
- Parameters:
command (str) – Name of a registered runnable subprocess command
args (str) – Arguments to be passed with the command
uncertainty_values (A tuple of enumerated values that are defined at time of construction.) –
A set of values describing the uncertainty configuration of a particular subprocess
Note
The values supported are {‘down’, ‘normal’, ‘up’}. These are the only values that the weatherers understand
Note
Right now the tuple size is 2, but could be expanded as more uncertainty dimensions are added
idx (int) – The numeric index of a particular subprocess If an index is passed in, the uncertainty values will be ignored.
- recv_from_task(task)¶
- handle_child_exception(response)¶
- stop()¶
- clean_task_files()¶