Skip to content

Commit

Permalink
Rename to execution api type, update job command output (NVIDIA#2306)
Browse files Browse the repository at this point in the history
* rename client category to execution api type

* fix output format
  • Loading branch information
SYangster authored Jan 23, 2024
1 parent 657d638 commit f5d2a2f
Show file tree
Hide file tree
Showing 30 changed files with 78 additions and 95 deletions.
95 changes: 38 additions & 57 deletions docs/user_guide/nvflare_cli/job_cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,42 @@ the job_templates.
The output should be similar to the following:

.. code-block::shell
.. code-block:: none
The following job templates are available:
------------------------------------------------------------------------------------------------------------------------
name Description Controller Type Client Category
------------------------------------------------------------------------------------------------------------------------
sag_cross_np scatter & gather and cross-site validation using numpy server client executor
sag_pt scatter & gather workflow using pytorch server client_api
sag_pt_ddp scatter & gather workflow using pytorch + ddp server client_api
sag_pt_deploy_map SAG workflow with pytorch, deploy_map, site-specific configs server client_api
sag_tf scatter & gather workflow using TensorFlow server client_api
stats_df FedStats: tabular data with pandas server stats executor
stats_image FedStats: image intensity histogram server stats executor
------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
name Description Controller Type Execution API Type
----------------------------------------------------------------------------------------------------------------------
cyclic_cc_pt client-controlled cyclic workflow with PyTorch ClientAPI tra client client_api
cyclic_pt server-controlled cyclic workflow with PyTorch ClientAPI tra server client_api
psi_csv private-set intersection for csv data server Executor
sag_cross_np scatter & gather and cross-site validation using numpy server client executor
sag_cse_pt scatter & gather workflow and cross-site evaluation with PyT server client_api
sag_gnn scatter & gather workflow for gnn learning server client_api
sag_nemo Scatter and Gather Workflow for NeMo server client_api
sag_np scatter & gather workflow using numpy server client_api
sag_np_cell_pipe scatter & gather workflow using numpy server client_api
sag_np_metrics scatter & gather workflow using numpy server client_api
sag_pt scatter & gather workflow using pytorch server client_api
sag_pt_deploy_map SAG workflow with pytorch, deploy_map, site-specific configs server client_api
sag_pt_executor scatter & gather workflow and cross-site evaluation with PyT server Executor
sag_pt_he scatter & gather workflow using pytorch and homomorphic encr server client_api
sag_pt_mlflow scatter & gather workflow using pytorch with MLflow tracking server client_api
sag_pt_model_learner scatter & gather workflow and cross-site evaluation with PyT server ModelLearner
sag_tf scatter & gather workflow using TensorFlow server client_api
sklearn_kmeans scikit-learn KMeans model server client_api
sklearn_linear scikit-learn linear model server client_api
sklearn_svm scikit-learn SVM model server client_api
stats_df FedStats: tabular data with pandas server stats executor
stats_image FedStats: image intensity histogram server stats executor
swarm_cse_pt Swarm Learning with Cross-Site Evaluation with PyTorch client client_api
swarm_cse_pt_model_l Swarm Learning with Cross-Site Evaluation with PyTorch Model client ModelLearner
vertical_xgb vertical federated xgboost server Executor
xgboost_tree xgboost horizontal tree-based collaboration model server client_api
----------------------------------------------------------------------------------------------------------------------
View all the available templates at the :github_nvflare_link:`FLARE Job Template Registry <job_templates>`.

Setting job_template path
-------------------------
Expand Down Expand Up @@ -90,20 +110,18 @@ The options for usage are as follows:

.. code-block::
usage: nvflare job create [-h] [-j [JOB_FOLDER]] [-w [TEMPLATE]] [-s [SCRIPT]] [-sd [SCRIPT_DIR]] [-f [CONFIG_FILE ...]] [-debug] [-force]
usage: nvflare job create [-h] [-j [JOB_FOLDER]] [-w [TEMPLATE]] [-sd [SCRIPT_DIR]] [-f [CONFIG_FILE [CONFIG_FILE ...]]] [-debug] [-force]
options:
optional arguments:
-h, --help show this help message and exit
-j [JOB_FOLDER], --job_folder [JOB_FOLDER]
job_folder path, default to ./current_job directory
-w [TEMPLATE], --template [TEMPLATE]
template name or template folder. You can use list_templates to see available jobs from job templates, pick name such as 'sag_pt' as template name. Alternatively, you can use the path to the job template folder, such as
job_templates/sag_pt
-s [SCRIPT], --script [SCRIPT]
code script such as train.py
template name or template folder. You can use list_templates to see available jobs from job templates, pick name such as 'sag_pt' as template name. Alternatively, you can use the path to the job
template folder, such as job_templates/sag_pt
-sd [SCRIPT_DIR], --script_dir [SCRIPT_DIR]
script directory contains additional related files. All files or directories under this directory will be copied over to the custom directory.
-f [CONFIG_FILE ...], --config_file [CONFIG_FILE ...]
-f [CONFIG_FILE [CONFIG_FILE ...]], --config_file [CONFIG_FILE [CONFIG_FILE ...]]
Training config file with corresponding optional key=value pairs. If key presents in the preceding config file, the value in the config file will be overwritten by the new value
-debug, --debug debug is on
-force, --force force create is on, if -force, overwrite existing configuration with newly created configurations
Expand Down Expand Up @@ -208,40 +226,3 @@ and change the app_1 batch_size to 4, app_2 batch_size to 6 for sag_pt_deploy_ma

The app names must be defined in the job template being used: in this case ``app_1``, ``app_2``, and ``app_server``,
are in ``sag_pt_deploy_map``.

***************************
FLARE Job Template Registry
***************************

Below is a table of all available :github_nvflare_link:`Job Templates <job_templates>`.

.. csv-table::
:header: Example,Execution API Type,Controller Type,Description
:widths: 18, 18, 10, 30

cyclic_cc_pt,client,client_api,client-controlled cyclic workflow with PyTorch ClientAPI trainer
cyclic_pt,server,client_api,server-controlled cyclic workflow with PyTorch ClientAPI trainer
psi_csv,server,Executor,private-set intersection for csv data
sag_cross_np,server,client_executor,scatter & gather and cross-site validation using numpy
sag_cse_pt,server,client_api,scatter & gather workflow and cross-site evaluation with PyTorch
sag_gnn,server,client_api,scatter & gather workflow for gnn learning
sag_nemo,server,client_api,Scatter and Gather Workflow for NeMo
sag_np,server,client_api,scatter & gather workflow using numpy
sag_np_cell_pipe,server,client_api,scatter & gather workflow using numpy
sag_np_metrics,server,client_api,scatter & gather workflow using numpy
sag_pt,server,client_api,scatter & gather workflow using pytorch
sag_pt_deploy_map,server,client_api,SAG workflow using pytorch with deploy_map & site-specific configs
sag_pt_executor,server,Executor,scatter & gather workflow and cross-site evaluation with PyTorch
sag_pt_he,server,client_api,scatter & gather workflow using pytorch and homomorphic encryption
sag_pt_mlflow,server,client_api,scatter & gather workflow using pytorch with MLflow tracking
sag_pt_model_learner,server,ModelLearner,scatter & gather workflow and cross-site evaluation with PyTorch
sag_tf,server,client_api,scatter & gather workflow using TensorFlow
sklearn_kmeans,server,client_api,scikit-learn KMeans model
sklearn_linear,server,client_api,scikit-learn linear model
sklearn_svm,server,client_api,scikit-learn SVM model
stats_df,server,stats_executor,FedStats: tabular data with pandas
stats_image,server,stats_executor,FedStats: image intensity histogram
swarm_cse_pt,client,client_api,Swarm Learning with Cross-Site Evaluation with PyTorch
swarm_cse_pt_model_learner,client,ModelLearner,Swarm Learning with Cross-Site Evaluation with PyTorch ModelLearner
vertical_xgb,server,Executor,vertical federated xgboost
xgboost_tree,server,client_api,xgboost horizontal tree-based collaboration model
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ When you open a notebook, select the kernel `nvflare_example` using the dropdown
| [Hello TensorFlow](./hello-world/hello-tf2/README.md) | TensorFlow2 | Example of using an image classifier using [FedAvg](https://arxiv.org/abs/1602.05629) and [TensorFlow](https://tensorflow.org/) as the deep learning training framework. |

## 2. Step-by-Step Examples
| Example | Dataset | Controller-Type | Client Category | Framework | Summary |
| Example | Dataset | Controller-Type | Execution API Type | Framework | Summary |
|---------|---------|-----------------|-----------------|-----------|---------|
| [image_stats](./hello-world/step-by-step/cifar10/stats/image_stats.ipynb) | CIFAR10 | server | Executor | Pandas | Example for federated stats image histogram calculation. |
| [sag](./hello-world/step-by-step/cifar10/sag/sag.ipynb) | CIFAR10 | server | Client API| PyTorch | Example for FedAvg with [ScatterAndGather](https://nvflare.readthedocs.io/en/main/apidocs/nvflare.app_common.workflows.scatter_and_gather.html) controller workflow using the Client API. |
Expand Down
2 changes: 1 addition & 1 deletion job_templates/cyclic_cc_pt/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "client-controlled cyclic workflow with PyTorch ClientAPI trainer"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "client"
}
2 changes: 1 addition & 1 deletion job_templates/cyclic_pt/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "server-controlled cyclic workflow with PyTorch ClientAPI trainer"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/psi_csv/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "private-set intersection for csv data"
client_category = "Executor"
execution_api_type = "Executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_cross_np/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather and cross-site validation using numpy"
client_category = "client executor"
execution_api_type = "client executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_cse_pt/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow and cross-site evaluation with PyTorch"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_gnn/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow for gnn learning"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_nemo/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Scatter and Gather Workflow for NeMo"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_np/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using numpy"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_np_cell_pipe/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using numpy"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_np_metrics/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using numpy"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using pytorch"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt_deploy_map/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "SAG workflow with pytorch, deploy_map, site-specific configs"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt_executor/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow and cross-site evaluation with PyTorch Executor"
client_category = "Executor"
execution_api_type = "Executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt_he/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using pytorch and homomorphic encryption"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt_mlflow/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using pytorch with MLflow tracking"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_pt_model_learner/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow and cross-site evaluation with PyTorch ModelLearner"
client_category = "ModelLearner"
execution_api_type = "ModelLearner"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sag_tf/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scatter & gather workflow using TensorFlow"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sklearn_kmeans/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scikit-learn KMeans model"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sklearn_linear/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scikit-learn linear model"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/sklearn_svm/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "scikit-learn SVM model"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/stats_df/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "FedStats: tabular data with pandas"
client_category = "stats executor"
execution_api_type = "stats executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/stats_image/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "FedStats: image intensity histogram"
client_category = "stats executor"
execution_api_type = "stats executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/swarm_cse_pt/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Swarm Learning with Cross-Site Evaluation with PyTorch"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "client"
}
2 changes: 1 addition & 1 deletion job_templates/swarm_cse_pt_model_learner/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Swarm Learning with Cross-Site Evaluation with PyTorch ModelLearner"
client_category = "ModelLearner"
execution_api_type = "ModelLearner"
controller_type = "client"
}
2 changes: 1 addition & 1 deletion job_templates/vertical_xgb/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "vertical federated xgboost"
client_category = "Executor"
execution_api_type = "Executor"
controller_type = "server"
}
2 changes: 1 addition & 1 deletion job_templates/xgboost_tree/info.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "xgboost horizontal tree-based collaboration model"
client_category = "client_api"
execution_api_type = "client_api"
controller_type = "server"
}
18 changes: 10 additions & 8 deletions nvflare/tool/job/job_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
JOB_CONFIG_FILE_NAME,
JOB_CONFIG_VAR_NAME,
JOB_CONFIG_VAR_VALUE,
JOB_INFO_CLIENT_TYPE,
JOB_INFO_CLIENT_TYPE_KEY,
JOB_INFO_CONF,
JOB_INFO_CONTROLLER_TYPE,
JOB_INFO_CONTROLLER_TYPE_KEY,
JOB_INFO_DESC,
JOB_INFO_DESC_KEY,
JOB_INFO_EXECUTION_API_TYPE,
JOB_INFO_EXECUTION_API_TYPE_KEY,
JOB_INFO_KEYS,
JOB_INFO_MD,
JOB_META_BASE_NAME,
Expand Down Expand Up @@ -318,13 +318,13 @@ def display_available_templates(template_index_conf):
print("-" * total_length)
name_fix_length = 20
description_fix_length = 60
controller_type_fix_length = 20
client_category_fix_length = 20
controller_type_fix_length = 17
execution_api_type_fix_length = 23
name = fix_length_format("name", name_fix_length)
description = fix_length_format(JOB_INFO_DESC, description_fix_length)
client_category = fix_length_format(JOB_INFO_CLIENT_TYPE, client_category_fix_length)
execution_api_type = fix_length_format(JOB_INFO_EXECUTION_API_TYPE, execution_api_type_fix_length)
controller_type = fix_length_format(JOB_INFO_CONTROLLER_TYPE, controller_type_fix_length)
print(" " * left_margin, name, description, controller_type, client_category)
print(" " * left_margin, name, description, controller_type, execution_api_type)
print("-" * total_length)
for file_path in sorted(template_registry.keys()):
name = os.path.basename(file_path)
Expand All @@ -333,9 +333,11 @@ def display_available_templates(template_index_conf):
template_info = template_registry.get(name)
name = fix_length_format(name, name_fix_length)
description = fix_length_format(template_info.get(JOB_INFO_DESC_KEY), description_fix_length)
client_category = fix_length_format(template_info.get(JOB_INFO_CLIENT_TYPE_KEY), client_category_fix_length)
execution_api_type = fix_length_format(
template_info.get(JOB_INFO_EXECUTION_API_TYPE_KEY), execution_api_type_fix_length
)
controller_type = fix_length_format(template_info.get(JOB_INFO_CONTROLLER_TYPE_KEY), controller_type_fix_length)
print(" " * left_margin, name, description, controller_type, client_category)
print(" " * left_margin, name, description, controller_type, execution_api_type)
print("-" * total_length)


Expand Down
Loading

0 comments on commit f5d2a2f

Please sign in to comment.