Python Code¶
Subpackages¶
Submodules¶
cis_interface.backwards module¶
This module allows for backward compatibility.
cis_interface.command_line module¶
cis_interface.config module¶
This module imports the configuration for cis_interface.
Todo
Remove reference to environment variables for accessing config options.
-
class
cis_interface.config.
CisConfigParser
(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False)[source]¶ Bases:
ConfigParser.ConfigParser
Config parser that returns None if option not provided on get.
-
cis_interface.config.
cfg_environment
(env=None, cfg=None)[source]¶ Set environment variables based on config options.
Parameters: - env (dict, optional) – Dictionary of environment variables that should be updated. Defaults to os.environ.
- cfg (
cis_interface.config.CisConfigParser
, optional) – Config parser with options that should be used to update the environment. Defaults tocis_interface.config.cis_cfg
.
cis_interface.runner module¶
This module provides tools for running models using cis_interface.
-
class
cis_interface.runner.
CisRunner
(modelYmls, namespace, host=None, rank=0, cis_debug_level=None, rmq_debug_level=None, cis_debug_prefix=None)[source]¶ Bases:
object
This class handles the orchestration of starting the model and IO drivers, monitoring their progress, and cleaning up on exit.
Parameters: - modelYmls (list) – List of paths to yaml files specifying the models that should be run.
- namespace (str) – Name that should be used to uniquely identify any RMQ exchange.
- host (str, optional) – Name of the host that the models will be launched from. Defaults to None.
- rank (int, optional) – Rank of this set of models if run in parallel. Defaults to 0.
- cis_debug_level (str, optional) – Level for CiS debug messages. Defaults to environment variable ‘PSI_DEBUG’.
- rmq_debug_level (str, optional) – Level for RabbitMQ debug messages. Defaults to environment variable ‘RMQ_DEBUG’.
- cis_debug_prefix (str, optional) – Prefix for CiS debug messages. Defaults to namespace.
-
namespace
¶ str – Name that should be used to uniquely identify any RMQ exchange.
-
host
¶ str – Name of the host that the models will be launched from.
-
rank
¶ int – Rank of this set of models if run in parallel.
-
modeldrivers
¶ list – Model drivers associated with this run.
-
inputdrivers
¶ list – Input drivers associated with this run.
-
outputdrivers
¶ list – Output drivers associated with this run.
..todo:: namespace, host, and rank do not seem strictly necessary.
-
closeChannels
(force_stop=False)[source]¶ Stop IO drivers and join the threads.
Parameters: force_stop (bool, optional) – If True, the terminate method is used to stop the drivers. Otherwise, the stop method is used. The stop method will try to exit gracefully while terminate will exit as quickly as possible. Defaults to False.
-
createDriver
(yml)[source]¶ Create a driver instance from the yaml information.
Parameters: yml (yaml) – Yaml object containing driver information. Returns: An instance of the specified driver. Return type: object
-
do_exits
(model)[source]¶ Perform exists for IO drivers associated with a model.
Parameters: model (dict) – Dictionary of model parameters including any associated IO drivers.
-
loadDrivers
()[source]¶ Load all of the necessary drivers, doing the IO drivers first and adding IO driver environmental variables back tot he models.
-
cis_interface.runner.
create_driver
(driver, name, args=None, **kwargs)[source]¶ Dynamically create a driver based on a string and other driver properties.
Parameters: - driver (str) – Name of the driver that should be created.
- name (str) – Name to give the driver.
- args (object, optional) – Second argument for drivers which take a minimum of two arguments. If None, the driver is assumed to take a minimum of one argument. Defaults to None.
- **kwargs – Additional keyword arguments are passed to the driver class.
Returns: Instance of the requested driver.
Return type:
-
cis_interface.runner.
get_runner
(models, **kwargs)[source]¶ Get runner for a set of models, getting run information from the environment.
Parameters: - models (list) – List of yaml files containing information on the models that should be run.
- **kwargs – Additonal keyword arguments are passed to CisRunner.
Returns: Runner for the provided models.
Return type: Raises: Exception
– If config option ‘namespace’ in ‘rmq’ section not set.
-
cis_interface.runner.
import_driver
(driver)[source]¶ Dynamically import a driver based on a string.
Parameters: driver (str) – Name of the driver that should be imported.
-
cis_interface.runner.
setup_cis_logging
(prog, level=None)[source]¶ Set the log lovel based on environment variable ‘PSI_DEBUG’. If the variable is not set, the log level is set to ‘NOTSET’.
Parameters:
-
cis_interface.runner.
setup_rmq_logging
(level=None)[source]¶ Set the log level for RabbitMQ to value of environment variable ‘RMQ_DEBUG’. If the variable is not set, the log level is set to ‘INFO’.
Parameters: level (str, optional) – String specifying the logging level. Defaults to None and the environment variable ‘RMQ_DEBUG’ is used.
cis_interface.tools module¶
This modules offers various tools.
-
cis_interface.tools.
ipc_queues
()[source]¶ Get a list of active IPC queues.
Returns: List of IPC queues. Return type: list
-
cis_interface.tools.
ipcrm
(options=[])[source]¶ Remove IPC constructs using the ipcrm command.
Parameters: options (list) – List of flags that should be used. Defaults to an empty list.
Module contents¶
This package provides a framework for integrating models across languages such that they can be run simultaneously, passing input back and forth.