:py:mod:`gnome.multi_model_broadcast` ===================================== .. py:module:: gnome.multi_model_broadcast Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.multi_model_broadcast.ModelConsumer gnome.multi_model_broadcast.ModelBroadcaster .. py:class:: ModelConsumer(task_port, model, ipc_folder='.') Bases: :py:obj:`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 .. py:method:: run() Method to be run in sub-process; can be overridden in sub-class .. py:method:: cleanup_inherited_files() .. py:method:: handle_cmd(msg) the IOLoop only uses recv_multipart(), so we will always get a list of byte strings. .. py:method:: _sleep(secs) Diagnostic only to simulate a long running command .. py:method:: _rewind() .. py:method:: _step() .. py:method:: _num_time_steps() .. py:method:: _full_run(rewind=True) .. py:method:: _get_wind_timeseries() just some model diag .. py:method:: _get_spill_amounts() .. py:method:: _set_wind_speed_uncertainty(up_or_down) .. py:method:: _set_spill_amount_uncertainty(up_or_down) .. py:method:: _get_spill_container_uncertainty() .. py:method:: _set_spill_container_uncertainty(uncertain) .. py:method:: _get_cache_dir() .. py:method:: _set_cache_dir() .. py:method:: _get_cache_enabled() .. py:method:: _set_cache_enabled(enabled) .. py:method:: _get_outputters() .. py:method:: _get_weatherer_attribute(idx, attr) .. py:method:: _set_weathering_output_only() .. py:class:: ModelBroadcaster(model, wind_speed_uncertainties, spill_amount_uncertainties, ipc_folder='.') Bases: :py:obj:`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. .. py:method:: __del__() .. py:method:: cmd(command, args, uncertainty_values=None, idx=None, in_parallel=True, timeout=None) Broadcast a command to the subprocesses, or target a specific subprocess. :param str command: Name of a registered runnable subprocess command :param str args: Arguments to be passed with the command :param uncertainty_values: 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 :type uncertainty_values: A tuple of enumerated values that are defined at time of construction. :param int idx: The numeric index of a particular subprocess If an index is passed in, the uncertainty values will be ignored. .. py:method:: recv_from_task(task) .. py:method:: handle_child_exception(response) .. py:method:: stop() .. py:method:: clean_task_files() .. py:method:: _get_available_ports(wind_speed_uncertainties, spill_amount_uncertainties) .. py:method:: _spawn_consumers() .. py:method:: _spawn_tasks() .. py:method:: _set_uncertainty(wind_speed_uncertainty, spill_amount_uncertainty) .. py:method:: _set_new_cache_dir(idx) .. py:method:: _disable_cache(idx) .. py:method:: _set_weathering_output_only(idx)