gnome.multi_model_broadcast

Module Contents

Classes

ModelConsumer

This is a consumer process that makes the model available

ModelBroadcaster

Here is where we spawn an array of model consumer processes

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

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.

_sleep(secs)

Diagnostic only to simulate a long running command

_rewind()
_step()
_num_time_steps()
_full_run(rewind=True)
_get_wind_timeseries()

just some model diag

_get_spill_amounts()
_set_wind_speed_uncertainty(up_or_down)
_set_spill_amount_uncertainty(up_or_down)
_get_spill_container_uncertainty()
_set_spill_container_uncertainty(uncertain)
_get_cache_dir()
_set_cache_dir()
_get_cache_enabled()
_set_cache_enabled(enabled)
_get_outputters()
_get_weatherer_attribute(idx, attr)
_set_weathering_output_only()
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.

__del__()
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()
_get_available_ports(wind_speed_uncertainties, spill_amount_uncertainties)
_spawn_consumers()
_spawn_tasks()
_set_uncertainty(wind_speed_uncertainty, spill_amount_uncertainty)
_set_new_cache_dir(idx)
_disable_cache(idx)
_set_weathering_output_only(idx)