Python Interface

yggdrasil.languages.Python.YggInterface.InterfaceComm(name, comm_class=None, global_scope=False, **kwargs)[source]

Short hand for initializing a default comm for use as an interface.

Parameters
  • name (str) – The name of the message queue.

  • comm_class (CommBase, optional) – Communication class that should be used. Defaults to DefaultComm if not provided.

  • global_scope (bool, optional) – If True, the comm will be checked for in the global scope before creating a new one. Defaults to False.

  • **kwargs – Additional keyword arguments are passed to DefaultComm.

yggdrasil.languages.Python.YggInterface.YggArrayInput(name, **kwargs)[source]

Get class for handling table-like formatted input as arrays.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggArrayOutput(name, **kwargs)[source]

Get class for handling table-like formatted output as arrays.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiArrayInput(name, **kwargs)[source]

Get class for handling table-like formatted input as arrays.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggAsciiTableInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiArrayOutput(name, fmt=None, **kwargs)[source]

Get class for handling table-like formatted output as arrays.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • fmt (str) – A C style format string specifying how each ‘row’ of output should be formated. This should include the newline character.

  • **kwargs – Additional keyword arguments are passed to YggAsciiTableOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiFileInput(name, **kwargs)[source]

Get class for generic ASCII input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiFileOutput(name, **kwargs)[source]

Get class for generic ASCII output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiTableInput(name, as_array=False, **kwargs)[source]

Get class for handling table-like formatted input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • as_array (bool, optional) – If True, recv returns the entire table array and can only be called once. If False, recv returns row entries. Default to False.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggAsciiTableOutput(name, fmt=None, as_array=False, **kwargs)[source]

Get class for handling table-like formatted output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • fmt (str) – A C style format string specifying how each ‘row’ of output should be formated. This should include the newline character.

  • as_array (bool, optional) – If True, send expects and entire array. If False, send expects the entries for one table row. Defaults to False.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggInit(_type, args=None, kwargs=None)[source]

Short interface to identify functions called by another language.

Parameters
  • _type (str) – Name of class that should be returned.

  • args (list, optional) – Additional arguments that should be passed to the class initializer.

  • kwargs (dict, optional) – Additional keyword arguments that should be passed to the class initializer.

Returns

An instance of the requested class.

Return type

obj

yggdrasil.languages.Python.YggInterface.YggInput(name, format_str=None, **kwargs)[source]

Get class for handling input from a message queue.

Parameters
  • name (str) – The name of the message queue. Combined with the suffix ‘_IN’, it should match an environment variable containing a message queue key.

  • format_str (str, optional) – C style format string that should be used to deserialize messages that are receieved into a list of python objects. Defaults to None and raw string messages are returned.

  • **kwargs – Additional keyword arguments are passed to the underlying comm.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggObjInput(name, **kwargs)[source]

Get class for handling Obj input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggObjOutput(name, **kwargs)[source]

Get class for handling Obj output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggOutput(name, format_str=None, **kwargs)[source]

Get class for handling output to a message queue.

Parameters
  • name (str) – The name of the message queue. Combined with the suffix ‘_OUT’, it should match an environment variable containing a message queue key.

  • format_str (str, optional) – C style format string that should be used to create a message from a list of python ojbects. Defaults to None and raw string messages are sent.

  • **kwargs – Additional keyword arguments are passed to the underlying comm.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPandasInput(name, **kwargs)[source]

Get class for handling Pandas input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPandasOutput(name, **kwargs)[source]

Get class for handling Pandas output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPickleInput(name, **kwargs)[source]

Get class for handling pickled input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPickleOutput(name, **kwargs)[source]

Get class for handling pickled output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPlyInput(name, **kwargs)[source]

Get class for handling Ply input.

Parameters
  • name (str) – The name of the input message queue that input should be received from.

  • **kwargs – Additional keyword arguments are passed to YggInput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggPlyOutput(name, **kwargs)[source]

Get class for handling Ply output.

Parameters
  • name (str) – The name of the message queue where output should be sent.

  • **kwargs – Additional keyword arguments are passed to YggOutput.

Returns

Communication object.

Return type

DefaultComm

yggdrasil.languages.Python.YggInterface.YggRpcClient(name, outfmt=None, infmt=None, **kwargs)[source]

Get class for handling requests and response to an RPC Server from a client.

Parameters
  • name (str) – The name of the server queues.

  • outfmt (str, optional) – Format string used to format variables in a message sent to the request queue. Defautls to ‘%s’.

  • infmt (str, optional) – Format string used to recover variables from messages received from the response queue. Defautls to ‘%s’.

  • **kwargs – Additional keyword arguments are passed to InterfaceComm.

Returns

class:.ClientComm: Communication object.

yggdrasil.languages.Python.YggInterface.YggRpcServer(name, infmt=None, outfmt=None, **kwargs)[source]

Get class for handling requests and response for an RPC Server.

Parameters
  • name (str) – The name of the server queues.

  • infmt (str, optional) – Format string used to recover variables from messages received from the request queue. Defaults to ‘%s’.

  • outfmt (str, optional) – Format string used to format variables in a message sent to the response queue. Defautls to ‘%s’.

  • **kwargs – Additional keyword arguments are passed to InterfaceComm.

Returns

class:.ServerComm: Communication object.

yggdrasil.languages.Python.YggInterface.YggTimesync(name='timesync', **kwargs)[source]

Get class for handling timestep synchronization requests.

Parameters
  • name (str, optional) – The name of the server queues. Defaults to ‘timesync’.

  • **kwargs – Additional keyword arguments are passed to InterfaceComm.

Returns

class:.ClientComm: Communication object.

yggdrasil.languages.Python.YggInterface.YggTimesyncServer(name='timesync', **kwargs)[source]

Get class for handling timestep synchronization requests on the driver side.

Parameters
  • name (str, optional) – The name of the server queues. Defaults to ‘timesync’.

  • **kwargs – Additional keyword arguments are passed to InterfaceComm.

Returns

class:.ServerComm: Communication object.

yggdrasil.languages.Python.YggInterface.bufMsgSize()[source]

int: Buffer size for average message.

yggdrasil.languages.Python.YggInterface.eof_msg()[source]

str: Message signalling end of file.

yggdrasil.languages.Python.YggInterface.maxMsgSize()[source]

int: The maximum message size.