nvflare.app_common.logging.job_log_receiver module
- class JobLogReceiver(dest_dir: str | None = None, idle_timeout: float = 30.0)[source]
Bases:
WidgetReceives live log data streamed by
JobLogStreamer.JobLogReceiveraccepts a live stream: each chunk is written directly to its final file as it arrives so that the log can be followed withtail -fon the server while the job runs. When the stream closes (normal EOF, job abort, or idle timeout) the file is handed to the job manager for storage.The destination file is written to
{dest_dir}/{job_id}/{client_name}/{log_file_name}, making it easy to locate and tail during a run.This widget can be placed in either of two locations:
- Job-level configuration (
config_fed_server.json) Add it via
job.to_server(JobLogReceiver())in the Job API, or declare it in the job’s server config. In this mode the handler is registered onSTART_RUN(and onABOUT_TO_START_RUNwhere available) so that the stream handler is wired up before any client chunk can arrive. The widget is only active for that specific job.- System-level resources (
resources.jsonon the server) Declare it as a system component so it is instantiated when the server process starts. In the long-lived parent process the handler is registered on
SYSTEM_STARTand remains active across jobs. In per-job server subprocesses (whereSYSTEM_STARTdoes not fire) the same instance re-registers on everySTART_RUNagainst the new job-scopedObjectStreamer.
The stream handler may be (re-)registered on every triggering event;
registry.setis idempotent for the same channel/topic pair.- Parameters:
dest_dir – directory where incoming log files are written. Defaults to the system temporary directory.
idle_timeout – seconds without any message (data or heartbeat) before the receiver declares the sender dead and closes the stream (default 30.0). Set to 0 to disable.
Init the Widget.
- Job-level configuration (