nvflare.app_common.logging.site_log_streamer module
- class SiteLogStreamer(log_file_name: str = 'log.txt', liveness_interval: float = 10.0, poll_interval: float = 0.5)[source]
Bases:
WidgetSite-level widget that injects a
JobLogStreamerinto every job that does not already declare one.Place this in the client’s
resources.jsonso that live log streaming is provided automatically for every job — without requiring each job to include aJobLogStreamerin its own configuration.On
BEFORE_JOB_LAUNCH(after the job config is deployed to disk but before the job subprocess starts)SiteLogStreamerreads the deployedconfig_fed_client.json. If noJobLogStreamercomponent is found, it appends one with the configured parameters and writes the file back. The job subprocess then picks up the modified config andJobLogStreamerruns inside the job as if the user had declared it explicitly.When configured for
error_log.txt,SiteLogStreameralso uploads a post-run snapshot fromCLIENT_PARENTonJOB_COMPLETED. This preserves error-log delivery for launch/config/bootstrap failures where the job subprocess never reachesSTART_RUNand therefore never loads the injectedJobLogStreamer.The server side must have a
JobLogReceiverin itsresources.json(or job config) to receive and store the stream.- Parameters:
log_file_name – base name of the log file to stream. Defaults to
WorkspaceConstants.LOG_FILE_NAME("log.txt").liveness_interval – seconds between heartbeat messages when no new log bytes have been written (default 10.0). Must be strictly less than the receiver’s
idle_timeout.poll_interval – seconds between polls when no new data has been written to the log (default 0.5).
Init the Widget.