nvflare.fuel.f3.streaming.file_downloader module

DEFAULT_CHUNK_SIZE = 5242880

This package implements file downloading capability based on the ObjDownloader framework. It provides implementation of the Producer and Consumer objects, required by ObjDownloader.

class FileDownloader[source]

Bases: ObjDownloader

classmethod add_file(transaction_id: str, file_name: str, ref_id=None, file_downloaded_cb=None, **cb_kwargs) str[source]

Add a file to be downloaded to the specified transaction.

Parameters:
  • transaction_id – ID of the transaction

  • file_name – name of the file to be downloaded

  • ref_id – ref id to be used, if provided

  • file_downloaded_cb – CB to be called when the file is done downloading

  • **cb_kwargs – args to be passed to the CB

Returns: reference id for the file.

The file_downloaded_cb must follow this signature:

cb(ref_id: str, to_site: str, status: str, file_name: str, **cb_kwargs)

classmethod download_file(from_fqcn: str, ref_id: str, per_request_timeout: float, cell: ~nvflare.fuel.f3.cellnet.cell.Cell, location: str | None = None, secure=False, optional=False, abort_signal=None) -> (<class 'str'>, typing.Optional[str])[source]

Download the referenced file from the file owner.

Parameters:
  • from_fqcn – FQCN of the file owner.

  • ref_id – reference ID of the file to be downloaded.

  • per_request_timeout – timeout for requests sent to the file owner.

  • cell – cell to be used for communicating to the file owner.

  • location – dir for keeping the received file. If not specified, will use temp dir.

  • secure – P2P private mode for communication

  • optional – supress log messages of communication

  • abort_signal – signal for aborting download.

Returns: tuple of (error message if any, full path of the downloaded file).

classmethod new_transaction(cell: Cell, timeout: float, timeout_cb, **cb_kwargs)[source]

Create a new file download transaction.

Parameters:
  • cell – the cell for communication with recipients

  • timeout – timeout for the transaction

  • timeout_cb – CB to be called when the transaction is timed out

  • **cb_kwargs – args to be passed to the CB

Returns: transaction id

The timeout_cb must follow this signature:

cb(tx_id, file_names: List[str], **cb_args)

download_file(from_fqcn: str, ref_id: str, per_request_timeout: float, cell: ~nvflare.fuel.f3.cellnet.cell.Cell, location: str | None = None, secure=False, optional=False, abort_signal=None) -> (<class 'str'>, typing.Optional[str])[source]