simulaqron.general package

Submodules

simulaqron.general.host_config module

class simulaqron.general.host_config.Host(name: str, hostname: str, port: int)[source]

Bases: Referenceable

Class representing a host that runs a SimulaQron Virtual Node. It holds the following information:

Parameters:
  • name (str) – Informal name of the host (e.g. Alice)

  • hostname (str) – Name of the node on the network (e.g. localhost or yournode.qutech.nl)

  • port (int) – Port number on hostname

class simulaqron.general.host_config.SocketsConfig(nets_config: NetworksConfiguration, network_name: str = 'default', config_type: NodeConfigType | str = 'vnode')[source]

Bases: Referenceable

Structure used to hold the sockets configuration for a particular component.

With version 4.0.0, we use the already in-memory information to create the SocketsConfig object. This avoids reading the file multiple times, which might have been updated by other processes in between reads. Additionally, this also simplifies the code, and reduces the potential source of bugs in the configuration read/write code.

Parameters:
  • nets_config (NetworksConfiguration) – NetworksConfiguration object, containing the loaded simulaqron_network.json file.

  • network_name (str) – The name of the network to use. This name must exist in the loaded network configuration object.

  • config_type (NodeConfigType | str) – The type of configuration to use. Valid values are instances of the NodeConfigType enum, or the string that represent each of those values.

filter(nodes_to_keep: List[str])[source]

Filter the loaded sockets configurations to only contain the given names. If a given node name is not found in the loaded one, it will simply be ignored from the exclusion process (i.e. it will not break the process)

Parameters:

nodes_to_keep (List[str]) – The node names to keep after filtering.

print_details(name: str)[source]

Prints the details of the specified node with name.

simulaqron.general.host_config.get_node_id_from_net_config(net_config: SocketsConfig, node_name: str) int[source]

Gets the node ID from the given sockets config and node name.

Note

node ID is the index of the node name of a sorted list of all the node names in the network.

Parameters:
  • net_config (SocketsConfig) – SocketsConfig object.

  • node_name (str) – The name of the node to get the node ID from.

Returns:

The node ID from the given sockets config and node name.

Return type:

int

simulaqron.general.errors module

exception simulaqron.general.errors.SimUnsupportedError[source]

Bases: RuntimeError

Raised when the SimulaQron does not support the configured simulation backend. Check NodeConfigType enum for valid values of the simulation backend.

Module contents