nvflare.app_common.widgets.job_stats_reporter module

class JobStatsReporter(filename: str = 'job_stats_run_summary.log', json_filename: str | None = 'job_stats_run_summary.json', error_filename: str | None = None, collect_resources: bool = True, resource_sample_interval: float = 1.0)[source]

Bases: Widget

Collect complete job, round, client, task, communication, and optional resource statistics.

Configure this component in both the server and client application configs. The client instance measures executor time/resources and attaches telemetry to each task result; the server instance produces the final report. When only configured on the server, server-observed timing and logical payload sizes are still reported, while client computation/resources are N/A.

The client telemetry header (AppConstants.JOB_STATS_CLIENT_TELEMETRY) is attached at AFTER_TASK_EXECUTION, i.e. BEFORE task-result filters run, so privacy filters can inspect or strip it, and the reported model-update size reflects the executor’s actual result (before any filter- or streaming-driven transformation). Client processing time therefore covers task-data filtering plus execution; result filtering and transmission are accounted to communication/wait time on the server side. The server sanitizes all received telemetry before use.

Parameters:
  • filename – human-readable report written to the server run directory.

  • json_filename – structured report filename, written by default. Set to None to disable JSON output.

  • error_filename – optional separate error report, created only when errors occurred.

  • collect_resources – whether client instances sample CPU/GPU/memory/battery during task execution.

  • resource_sample_interval – resource sampling interval in seconds.

static format_errors(errors: List[dict]) str[source]
format_report(summary: dict) str[source]

Render the structured summary as a human-readable run summary log.

get_summary(fl_ctx: FLContext | None = None) dict[source]

Build the structured server-side job statistics summary.

handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

class JobStatusCode[source]

Bases: object

FAILURE = 'FAILURE'
PARTIAL = 'PARTIAL'
PARTIAL_SUCCESS = 'PARTIAL'
SUCCESS = 'SUCCESS'