nvflare.fuel.utils.pipe.cell_pipe module

class CellPipe(mode: Mode, site_name: str, token: str, root_url: str = '', secure_mode: bool = True, workspace_dir: str = '')[source]

Bases: Pipe

CellPipe is an implementation of Pipe that utilizes the Cell from NVFlare’s foundation layer (f3) to do the communication.

The constructor of the CellPipe.

Parameters:
  • mode – passive or active mode

  • site_name (str) – name of the FLARE site

  • token (str) – unique id to guarantee the uniqueness of cell’s FQCN.

  • root_url (str) – the root url of the cellnet that the pipe’s cell will join

  • secure_mode (bool) – whether connection to the root is secure (TLS)

  • workspace_dir (str) – the directory that contains startup for joining the cellnet. Required only in secure_mode

can_resend() bool[source]

Whether the pipe is able to resend a message.

clear()[source]

Clear the pipe

close()[source]

Close the pipe

Returns: None

export(export_mode: str) Tuple[str, dict][source]

Exports attributes.

Parameters:

export_mode (str) – export to peer (ExportMode.PEER) or to self (ExportMode.SELF).

Returns:

A tuple of (export section name, arguments to be exported)

get_last_peer_active_time()[source]

Get the last time that the peer is known to be active

Returns: the last time that the peer is known to be active; or 0 if this info is not available

open(name: str)[source]

Open the pipe

Parameters:

name – name of the pipe

receive(timeout=None) None | Message[source]

Try to receive message from peer.

Parameters:

timeout – how long (number of seconds) to try If not specified, return right away.

Returns:

the message received; or None if no message

release_send_cache(msg: Message)[source]

Clear the cached CellMessage that was attached to msg by send().

The cache is created on the first send() call so that retries reuse the already-serialized CellMessage. Once the retry loop exits this cache is no longer needed. Dropping it allows the encoded payload bytes and any lingering references to be reclaimed by GC promptly, rather than waiting for the Message object itself to go out of scope.

send(msg: Message, timeout=None) bool[source]

Sends the specified message to the peer.

Parameters:
  • msg – the message to be sent

  • timeout – if specified, number of secs to wait for the peer to read the message. If not specified, wait indefinitely.

Returns:

Whether the message is read by the peer.

set_cell_cb(channel_name: str)[source]