NVIDIA FLARE Application¶
The NVIDIA FLARE application defines how the server and client should run. Note that in the scope of one job, each site will only run one application.
The structure of the app folder needs to be:
app_folder/
config/
config_fed_client.json [required if this app needs to be deployed to clients]
config_fed_server.json [required if this app needs to be deployed to server]
custom/
[any of your custom code].py
[another file with custom code].py
...
resources/
log.config
Note
Note that apps can be configured to run on certain sites in a job’s deploy_map configuration. An application can also be run without a job. To do this, simply submit an app as a job and a default deploy map of all sites will be used.
Note
If the same application is going to be deployed on both server and clients, it can contain both
config_fed_server.json
and config_fed_client.json
Note
The configuration JSON files config_fed_server.json and config_fed_client.json may be in the root folder of the FL application or in a sub-folder (for example: config) of the FL application.
FL server configuration¶
config_fed_server.json
is the FL server configuration file.
Example:
{
"format_version": 2,
"server": {
"heart_beat_timeout": 600
},
"task_data_filters": [],
"task_result_filters": [],
"components": [
{
"id": "persistor",
"path": "np_model_persistor.NPModelPersistor",
"args": {}
},
{
"id": "shareable_generator",
"path": "nvflare.app_common.shareablegenerators.full_model_shareable_generator.FullModelShareableGenerator",
"args": {}
},
{
"id": "aggregator",
"path": "nvflare.app_common.aggregators.intime_accumulate_model_aggregator.InTimeAccumulateWeightedAggregator",
"args": {}
}
],
"workflows": [
{
"id": "fed_avg_ctl",
"path": "nvflare.app_common.workflows.fed_avg.fed_avg_ctl.FedAvgController",
"args": {
"min_clients": 2,
"num_rounds": 10,
"start_round": 0,
"wait_time_after_min_received": 10,
"aggregator_id": "aggregator",
"persistor_id": "persistor",
"shareable_generator_id": "shareable_generator",
"train_task_name": "train",
"train_timeout": 6000
}
}
]
}
Key |
Notes |
---|---|
format_version |
The NVIDIA FLARE version for this config |
server |
Specify server-specific attributes like heart_beat_timeout for seconds before the heart beat times out |
task_data_filters |
What filters to apply to data leaving server, see Filters |
task_result_filters |
What filters to apply to data arriving to server, see Filters |
components |
All of the Components to use |
workflows |
What Workflows to use, see Controllers and Controller API |
FL client configuration¶
config_fed_client.json
is the FL client configuration file.
Example:
{
"format_version": 2,
"executors": [
{
"tasks": [
"train"
],
"executor": {
"path": "np_trainer.NPTrainer"
}
}
],
"task_result_filters": [],
"task_data_filters": [],
"components": []
}
Key |
Notes |
---|---|
format_version |
The NVIDIA FLARE version for this config |
executors |
The configuration for Tasks and Executors which now includes Trainers |
task_data_filters |
What filters to apply to data arriving at client, see Filters |
task_result_filters |
What filters to apply to data leaving client, Filters |
components |
All of the Components to use |
Custom code¶
You can write your own components and bring your own code (BYOC) following the Programming Guide.
To use it in your application, put the code inside the “custom” folder of the application folder and make sure BYOC is enabled and allowed.
In your server or client config, use path to refer to that component.
Custom code config example¶
For example, with a SimpleTrainer
class stored in a file my_trainer.py
inside the custom folder,
the client config should have the following in order to configure it as an Executor:
...
"executor": {
"path": "my_trainer.SimpleTrainer",
"args": {}
},
...
Note
Configuration of Executor Tasks is ignored here.
Please follow Getting Started to learn more.
Troubleshooting BYOC¶
In 2.2.1, authorization has been redesigned and BYOC is no longer controlled through settings at provisioning, but instead by each site’s authorization.json (in the local folder of the workspace). BYOC is a right and can be restricted to certain roles or even orgs or users. See Federated Authorization for details.
Resources¶
A log.config
is needed inside the resources folder.
This file is for the Python logger to use.
If you don’t want to customize the log behavior, you can use the same log.config
from one of
the example application folder.
[loggers]
keys=root,modelLogger
[handlers]
keys=consoleHandler
[formatters]
keys=fullFormatter
[logger_root]
level=INFO
handlers=consoleHandler
[logger_modelLogger]
level=DEBUG
handlers=consoleHandler
qualname=modelLogger
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=fullFormatter
args=(sys.stdout,)
[formatter_fullFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s