nvflare.fuel.utils.pipe.file_pipe module

class FilePipe(mode: Mode, root_path: str, file_check_interval=0.1)[source]

Bases: Pipe

Implementation of communication through the file system.

Parameters:
  • mode (Mode) – Mode of the endpoint. A pipe has two endpoints. An endpoint can be either the one that initiates communication or the one listening.

  • root_path (str) – root path for this file pipe, folders and files will be created under this root_path for communication.

  • file_check_interval (float) – how often should to check the file exists.

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)

open(name: str)[source]

Open the pipe

Parameters:

name – name of the pipe

receive(timeout=None)[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

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_file_accessor(accessor: FileAccessor)[source]

Sets the file accessor to be used by the pipe. The default file accessor is FobsFileAccessor.

Parameters:

accessor – the accessor to be used.

x_get(timeout=None)[source]
x_put(msg: Message, timeout) bool[source]
Parameters:
  • msg

  • timeout

Returns: whether file is read by the peer

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