nvflare.fuel.f3.streaming.file_streamer module

class FileHandler(file_cb: Callable)[source]

Bases: object

handle_file_cb(future: StreamFuture, stream: Stream, resume: bool, *args, **kwargs) int[source]
class FileStream(file_name: str, headers: dict | None)[source]

Bases: Stream

Constructor for stream

Parameters:
  • size – The total size of stream. 0 if unknown

  • headers – Optional headers to be passed to the receiver

close()[source]

Close the stream

read(chunk_size: int) bytes | bytearray | memoryview | list[source]

Read and return up to chunk_size bytes. It can return less but not more than the chunk_size. An empty bytes object is returned if the stream reaches the end.

Parameters:

chunk_size – Up to (but maybe less) this many bytes will be returned

Returns:

Binary data. If empty, it means the stream is depleted (EOF)

class FileStreamer(byte_streamer: ByteStreamer, byte_receiver: ByteReceiver)[source]

Bases: object

register_file_callback(channel, topic, file_cb: Callable, *args, **kwargs)[source]
send(channel: str, topic: str, target: str, message: Message, secure=False, optional=False) StreamFuture[source]