nvflare.client.config module

class ClientConfig(config: Dict | None = None)[source]

Bases: object

Config class used in nvflare.client module.

Note

The config has the following keys:

EXCHANGE_FORMAT: Format to exchange, pytorch, raw, or numpy
TRANSFER_TYPE: Either FULL or DIFF (means difference)
TRAIN_WITH_EVAL: Whether train task needs to also do evaluation
TRAIN_TASK_NAME: Name of the train task
EVAL_TASK_NAME: Name of the evaluate task
SUBMIT_MODEL_TASK_NAME: Name of the submit_model task
PIPE_CHANNEL_NAME: Channel name of the pipe
PIPE: pipe section
CLASS_NAME: Class name
ARG: Arguments
SITE_NAME: Site name
JOB_ID: Job id
TASK_EXCHANGE: TASK_EXCHANGE section
METRICS_EXCHANGE: METRICS_EXCHANGE section

Example

The content of config looks like:

{
  "METRICS_EXCHANGE": {
    "pipe_channel_name": "metric",
    "pipe": {
      "CLASS_NAME": "nvflare.fuel.utils.pipe.cell_pipe.CellPipe",
      "ARG": {
        "mode": "ACTIVE",
        "site_name": "site-1",
        "token": "simulate_job",
        "root_url": "tcp://0:51893",
        "secure_mode": false,
        "workspace_dir": "xxx"
      }
    }
  },
  "SITE_NAME": "site-1",
  "JOB_ID": "simulate_job",
  "TASK_EXCHANGE": {
    "train_with_eval": true,
    "exchange_format": "numpy",
    "transfer_type": "DIFF",
    "train_task_name": "train",
    "eval_task_name": "validate",
    "submit_model_task_name": "submit_model",
    "pipe_channel_name": "task",
    "pipe": {
      "CLASS_NAME": "nvflare.fuel.utils.pipe.cell_pipe.CellPipe",
      "ARG": {
        "mode": "ACTIVE",
        "site_name": "site-1",
        "token": "simulate_job",
        "root_url": "tcp://0:51893",
        "secure_mode": false,
        "workspace_dir": "xxx"
      }
    }
  }
}
get_auth_token()[source]
get_auth_token_signature()[source]
get_config() Dict[source]
get_connection_security()[source]
get_cp_conn_props()[source]
get_download_complete_timeout() float[source]

Return timeout (seconds) for subprocess to wait for the server to finish downloading its result.

After send_to_peer() ACKs, the server asynchronously downloads tensors from the subprocess DownloadService. This timeout gates subprocess exit so the process does not disappear before the download completes. Defaults to 1800 s (30 min) for large-model transfers. Recipe-based external-process jobs can override it with recipe.add_client_config({“download_complete_timeout”: N}).

get_eval_task()[source]
get_exchange_format() str[source]
get_heartbeat_timeout()[source]
get_launch_once() bool[source]

Return whether the subprocess is launched once for the entire job (True) or per-round (False).

True → subprocess handles multiple rounds; must NOT os._exit() after each send. False → subprocess handles one round; must os._exit() after download so the deferred-stop

poller on the CJ side unblocks (default, preserves original behaviour).

get_max_resends()[source]

Return the maximum number of pipe send retries for submitting task results.

None means unlimited; the default of 3 bounds the retry window and prevents unbounded large-result resend transactions. In recipe-based external-process jobs, the parent executor writes this value into the Client API config and applies recipe.add_client_config({“max_resends”: N}) as a per-job override.

get_pipe_args(section: str) dict[source]
get_pipe_channel_name(section: str) str[source]
get_pipe_class(section: str) str[source]
get_relay_conn_props()[source]
get_root_conn_props()[source]
get_server_expected_format() str[source]
get_site_name()[source]
get_submit_model_task()[source]
get_submit_result_timeout() float[source]

Return the timeout (seconds) for the subprocess to wait for CJ to ACK a result message.

The value is read from the TASK_EXCHANGE section of the config, which is written by ClientAPILauncherExecutor.prepare_config_for_launch(). If absent, a safe default of 300 s is returned — large enough for a single-chunk ACK with reverse PASS_THROUGH, and a reasonable upper bound for direct (non-PASS_THROUGH) transfers at typical throughputs.

Recipe-based external-process jobs can override it with recipe.add_client_config({“submit_result_timeout”: N}) without touching process-level defaults.

get_train_task()[source]
get_transfer_type() str[source]
to_json(config_file: str)[source]
class ConfigKey[source]

Bases: object

ARG = 'ARG'
CLASS_NAME = 'CLASS_NAME'
CUDA_EMPTY_CACHE = 'cuda_empty_cache'
DOWNLOAD_COMPLETE_TIMEOUT = 'download_complete_timeout'
EVAL_TASK_NAME = 'eval_task_name'
EXCHANGE_FORMAT = 'exchange_format'
HEARTBEAT_TIMEOUT = 'HEARTBEAT_TIMEOUT'
LAUNCH_ONCE = 'launch_once'
MAX_RESENDS = 'max_resends'
MEMORY_GC_ROUNDS = 'memory_gc_rounds'
METRICS_EXCHANGE = 'METRICS_EXCHANGE'
PIPE = 'pipe'
PIPE_CHANNEL_NAME = 'pipe_channel_name'
SERVER_EXPECTED_FORMAT = 'server_expected_format'
SUBMIT_MODEL_TASK_NAME = 'submit_model_task_name'
SUBMIT_RESULT_TIMEOUT = 'submit_result_timeout'
TASK_EXCHANGE = 'TASK_EXCHANGE'
TASK_NAME = 'TASK_NAME'
TRAIN_TASK_NAME = 'train_task_name'
TRAIN_WITH_EVAL = 'train_with_eval'
TRANSFER_TYPE = 'transfer_type'
class ExchangeFormat(value)[source]

Bases: str, Enum

An enumeration.

KERAS_LAYER_WEIGHTS = 'keras_layer_weights'
NUMPY = 'numpy'
PYTORCH = 'pytorch'
RAW = 'raw'
class TransferType(value)[source]

Bases: str, Enum

An enumeration.

DIFF = 'DIFF'
FULL = 'FULL'
from_file(config_file: str)[source]
write_config_to_file(config_data: dict, config_file_path: str)[source]

Writes client api config file.

Parameters:
  • config_data (dict) – data to be updated.

  • config_file_path (str) – filepath to write.