Input/Output Drivers — cis_interface 0.3.0 documentation

# Input/Output Drivers

## File Input Drivers

class `cis_interface.drivers.FileInputDriver.` `FileInputDriver`(name, args, **kwargs)

  Class that sends messages read from a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.AsciiFileInputDriver.` `AsciiFileInputDriver`(name, args, **kwargs)

  Class that sends lines from an ASCII file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str or dict) – Path to the file that messages should be read from or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiFile object. comment (str, optional) – String that should be used to identify comments. Default set by `AsciiFile`. newline (str, optional) – String that should be used to identify the end of a line. Default set by `AsciiFile`. **kwargs – Additional keyword arguments are passed to parent class.

class `cis_interface.drivers.AsciiTableInputDriver.` `AsciiTableInputDriver`(name, args, **kwargs)

  Class to handle input from an ASCII table.

  Parameters: | name (str) – Name of the input queue to send messages to. args (str or dict) – Path to the file that messages should be read from or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiTable object. format_str (str) – Format string that should be used to format output in the case that the io_mode is ‘w’ (write). It is not required if the io_mode is any other value. field_names (list, optional) – List of column names. Defaults to None. field_units (list, optional) – List of column units. Defaults to None. use_astropy (bool, optional) – If True, astropy is used to determine a table’s format if it is installed. If False, a format string must be contained in the table. Defaults to False. delimiter (str, optional) – String that should be used to separate columns. Default set by serialize._default_delimiter. comment (str, optional) – String that should be used to identify comments. Default set by serialize._default_comment. newline (str, optional) – String that should be used to identify the end of a line. Default set by serialize._default_newline. as_array (bool, optional) – If True, the table contents are sent all at once as an array. Defaults to False. **kwargs – Additional keyword arguments are passed to parent class.

  `update_serializer`(msg)

    Update the serializer for the output comm based on input.

class `cis_interface.drivers.PickleFileInputDriver.` `PickleFileInputDriver`(name, args, **kwargs)

  Class that sends messages read from a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.PandasFileInputDriver.` `PandasFileInputDriver`(name, args, **kwargs)

  Class to handle input from a Pandas csv file.

  Parameters: | name (str) – Name of the input queue to send messages to. args (str or dict) – Path to the file that messages should be read from. delimiter (str, optional) – String that should be used to separate columns. Defaults to ‘t’. **kwargs – Additional keyword arguments are passed to parent class.

  `update_serializer`(msg)

    Update the serializer for the output comm based on input.

class `cis_interface.drivers.PlyFileInputDriver.` `PlyFileInputDriver`(name, args, **kwargs)

  Class that sends messages read from a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.ObjFileInputDriver.` `ObjFileInputDriver`(name, args, **kwargs)

  Class that sends messages read from a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.MatInputDriver.` `MatInputDriver`(name, args, **kwargs)

  Class that sends pickled dictionaries of matricies read from a .mat file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the .mat file that messages should be read from. **kwargs – Additional keyword arguments are passed to parent class.

## File Output Drivers

class `cis_interface.drivers.FileOutputDriver.` `FileOutputDriver`(name, path, in_temp=False, **kwargs)

  Class to handle output of received messages to a file.

  Parameters: | name (str) – Name of the output queue to receive messages from. path (str) – Path to the file that messages should be written to. in_temp (bool, str, optional) – If True or ‘True’, the path will be considered relative to the temporary directory. Defaults to False. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.AsciiFileOutputDriver.` `AsciiFileOutputDriver`(name, path, in_temp=False, **kwargs)

  Class to handle output line by line to an ASCII file.

  Parameters: | name (str) – Name of the output queue to receive messages from. args (str or dict) – Path to the file that messages should be written to or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiFile object. comment (str, optional) – String that should be used to identify comments. Default set by `AsciiFile`. newline (str, optional) – String that should be used to identify the end of a line. Default set by `AsciiFile`. **kwargs – Additional keyword arguments are passed to parent class.

class `cis_interface.drivers.PickleFileOutputDriver.` `PickleFileOutputDriver`(name, args, **kwargs)

  Class that writes received messages to a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.PandasFileOutputDriver.` `PandasFileOutputDriver`(name, args, **kwargs)

  Class to handle output of received messages to a Pandas csv file.

  Parameters: | name (str) – Name of the output queue to receive messages from. args (str or dict) – Path to the file that messages should be written to. delimiter (str, optional) – String that should be used to separate columns. Defaults to ‘t’. **kwargs – Additional keyword arguments are passed to parent class.

  `update_serializer`(msg)

    Update the serializer for the output comm based on input.

class `cis_interface.drivers.PlyFileOutputDriver.` `PlyFileOutputDriver`(name, args, **kwargs)

  Class that writes received messages to a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.ObjFileOutputDriver.` `ObjFileOutputDriver`(name, args, **kwargs)

  Class that writes received messages to a file.

  Parameters: | name (str) – Name of the queue that messages should be sent to. args (str) – Path to the file that messages should be read from. **kwargs – Additional keyword arguments are passed to the parent class.

class `cis_interface.drivers.MatOutputDriver.` `MatOutputDriver`(name, args, **kwargs)

  Class to handle output to .mat Matlab files.

  Parameters: | name (str) – Name of the output queue to receive messages from. args (str) – Path to the file that messages should be written to. **kwargs – Additional keyword arguments are passed to parent class.

## General Input Drivers

class `cis_interface.drivers.InputDriver.` `InputDriver`(name, args, **kwargs)

  Driver for receiving input from another model’s comm via a local comm.

  Parameters: | name (str) – The name of the local message comm that the driver should connect to. args (str) – The name of the other message comm that the driver should connect to. **kwargs – Additional keyword arguments are passed to parent class.

class `cis_interface.drivers.RMQInputDriver.` `RMQInputDriver`(name, args, **kwargs)

  Driver for receiving input from a RabbitMQ server via a local comm.

  Parameters: | name (str) – The name of the local message queue that the driver should connect to. args (str) – The name of the RabbitMQ message queue that the driver should connect to. **kwargs – Additional keyword arguments are passed to parent class.

## General Output Drivers

class `cis_interface.drivers.InputDriver.` `InputDriver`(name, args, **kwargs)

  Driver for receiving input from another model’s comm via a local comm.

  Parameters: | name (str) – The name of the local message comm that the driver should connect to. args (str) – The name of the other message comm that the driver should connect to. **kwargs – Additional keyword arguments are passed to parent class.

class `cis_interface.drivers.RMQInputDriver.` `RMQInputDriver`(name, args, **kwargs)

  Driver for receiving input from a RabbitMQ server via a local comm.

  Parameters: | name (str) – The name of the local message queue that the driver should connect to. args (str) – The name of the RabbitMQ message queue that the driver should connect to. **kwargs – Additional keyword arguments are passed to parent class.

## Input/Output Drivers

class `cis_interface.drivers.RPCDriver.` `RPCDriver`(name, args=None, **kwargs)

  Base class for any driver that requires to access to input & output queues for RPC type functionality.

  Parameters: | name (str) – The name of the message queue set that the driver should connect to. (name + “_IN” and name + “_OUT”) **kwargs – Additional keyword arguments are passed to parent class.

  `icomm`

    `cis_interface.drivers.CommDriver` – Driver for the input message queue.

  `ocomm`

    `cis_interface.drivers.CommDriver` – Driver for the output message ueue.

  `cleanup`()

    Perform cleanup for IPC drivers.

  `close_comms`()

    Close the IPC comms.

  `comms_open`

    bool – True if both input and output comms open.

  `do_terminate`()

    Terminate input/output comm drivers.

  `graceful_stop`()

    Allow the IPC comms to terminate gracefully.

  `is_valid`

    bool – True if both comms are open and parent class is valid.

  `n_msg_in`

    int – The number of messages in the input comm.

  `n_msg_out`

    int – The number of messages in the output comm.

  `on_model_exit`()

    Actions to perform when the associated model driver is finished.

  `printStatus`()

    Print information on the status of the driver.

  `recv`(*args, **kwargs)

    Receive message smaller than maxMsgSize from the input comm.

    Parameters: | *args – Arguments are passed to input comm recv method. **kwargs – Keyword arguments are passed to input comm recv method.
    Returns: | Success or failure of recv and the received message.
    Return type: | tuple (bool, str)

  `recv_nolimit`(*args, **kwargs)

    Receive message larger than maxMsgSize from the output comm.

    Parameters: | *args – Arguments are passed to input comm recv_nolimit method. **kwargs – Keyword arguments are passed to input comm recv_nolimit method.
    Returns: | Success or failure of recv and the received message.
    Return type: | tuple (bool, str)

  `send`(data, *args, **kwargs)

    Send message smaller than maxMsgSize to the output comm.

    Parameters: | data (str) – Message to be sent. *args – Arguments are passed to output comm send method. **kwargs – Keyword arguments are passed to output comm send method.
    Returns: | Succes or failure of send.
    Return type: | bool

  `send_nolimit`(data, *args, **kwargs)

    Send message larger than maxMsgSize to the input comm.

    Parameters: | data (str) – Message to be sent. *args – Arguments are passed to output comm send_nolimit method. **kwargs – Keyword arguments are passed to output comm send_nolimit method.
    Returns: | Succes or failure of send.
    Return type: | bool

  `start`()

    Run the input/output comm drivers.

class `cis_interface.drivers.ClientDriver.` `ClientDriver`(model_request_name, request_name=None, comm=None, comm_address=None, **kwargs)

  Alias for ClientRequestDriver.

class `cis_interface.drivers.ServerDriver.` `ServerDriver`(model_request_name, request_name=None, comm=None, comm_address=None, **kwargs)

  Alias for ServerRequestDriver.

class `cis_interface.drivers.RMQClientDriver.` `RMQClientDriver`(*args, **kwargs)

  Class for handling an RMQ client.

  Parameters: | *args – Arguments are passed to parent class. **kwargs – Keyword arguments are passed to parent class.

class `cis_interface.drivers.RMQServerDriver.` `RMQServerDriver`(*args, **kwargs)

  Class for handling an RMQ server.

  Parameters: | *args – Arguments are passed to parent class. **kwargs – Keyword arguments are passed to parent class.