libmuscle.port module

class libmuscle.port.Port(name: str, operator: Operator, is_vector: bool, is_connected: bool, our_ndims: int, peer_dims: List[int])[source]

Bases: Port

Represents a gateway to the outside world.

Ports can be used to send or receive messages. They have a name and an operator, as well as a set of dimensions that determines the valid slot indices for sending or receiving on this port.

name

Name of this port.

Type

Identifier

operator

Operator associated with this port.

Type

Operator

Create a Port.

Parameters
  • name – Name of this port.

  • operator – Corresponding operator.

  • is_vector – Whether this is a vector port.

  • is_connected – Whether this port is connected to a peer.

  • our_ndims – Number of dimensions of our instance set.

  • peer_dims – Dimensions of the peer instance set of this port.

get_length() int[source]

Returns the length of this port.

Raises

RuntimeError – If this port is a scalar port.

is_connected() bool[source]

Returns whether the port is connected to a peer.

Returns

True if there is a peer, False if there is not.

is_open(slot: Optional[int] = None) bool[source]

Returns whether this port is open.

is_resizable() bool[source]

Returns whether this port can be resized.

is_vector() bool[source]

Returns whether this is a vector port.

Returns

True if it is vector, False if it is scalar.

set_closed(slot: Optional[int] = None) None[source]

Marks this port as closed.

set_length(length: int) None[source]

Sets the length of a resizable vector port.

Only call this if is_resizable() returns True.

Parameters

length – The new length.

Raises

RuntimeError – If the port is not resizable.

libmuscle.port.optional_port_to_grpc(port: Optional[Port]) Optional[Port][source]
libmuscle.port.port_from_grpc(port: Port) Port[source]
libmuscle.port.port_to_grpc(port: Port) Port[source]