Skip to content

473 Update NVFlare example #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 19 additions & 97 deletions federated_learning/nvflare/nvflare_spleen_example/3-Admin.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -46,17 +46,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a working folder for the admin exists!!!\n"
]
}
],
"outputs": [],
"source": [
"admin_path = \"poc/admin/startup/\"\n",
"\n",
Expand All @@ -73,50 +65,28 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!mkdir -p poc/admin/transfer\n",
"!cp -r hello_monai/ poc/admin/transfer/"
"!cp -r hello-monai/ poc/admin/transfer/"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['hello_monai']"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"os.listdir(\"poc/admin/transfer/\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['fl_admin.sh']"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"os.listdir(admin_path)"
]
Expand Down Expand Up @@ -144,23 +114,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<a href=\"\", data-commandlinker-command=\"terminal:create-new\"> Open a new terminal</a>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"HTML('<a href=\"\", data-commandlinker-command=\"terminal:create-new\"> Open a new terminal</a>')"
]
Expand Down Expand Up @@ -192,51 +148,18 @@
"\n",
"The commands can be:\n",
"```\n",
"upload_app hello_monai\n",
"upload_app hello-monai\n",
"set_run_number 1\n",
"deploy_app hello_monai server\n",
"deploy_app hello_monai client\n",
"```\n",
"\n",
"Now, let's check if the folder has been distributed into the server and all client(s):"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"config files on server: ['app_server', 'fl_app.txt']\n",
" \n",
"config files on site-1: ['app_site-1', 'fl_app.txt']\n",
" \n",
"config files on site-2: ['fl_app.txt', 'app_site-2']\n",
" \n"
]
}
],
"source": [
"run_file = \"run_1\"\n",
"\n",
"poc_path = \"poc/\"\n",
"\n",
"for name in [\"server\", \"site-1\", \"site-2\"]:\n",
" path = os.path.join(poc_path, name, run_file)\n",
" if os.path.exists(path):\n",
" print(\"config files on {}: {}\".\n",
" format(name, os.listdir(path)))\n",
" print(\" \")"
"deploy_app hello-monai server\n",
"deploy_app hello-monai client\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This example prepares two different data list files: `dataset_part1.json` and `dataset_part2.json`, and they have the same validation set and totally different training set. The default file used in `config_train.json` is `config/dataset_part1.json`. Therefore, if you want to let two clients train on different data, you can switch to use `dataset_part2.json` for `org1-b`.\n",
"This example prepares two different data list files: `dataset_part1.json` and `dataset_part2.json`, and they have the same validation set and totally different training sets. The default file used in `config_train.json` is `config/dataset_part1.json`. Therefore, if you want to let two clients train on different data, you can switch to use `dataset_part2.json` for `org1-b`.\n",
"\n",
"[Link to site-1 config](poc/site-1/run_1/app_site-1/config/config_train.json)\n",
"\n",
Expand All @@ -250,13 +173,12 @@
"### (Optional) Copy Dataset\n",
"\n",
"After starting a client (for example `site-1`), the Spleen dataset will be downloaded into:\n",
"`run_1/app_site-1/Task09_Spleen.tar`.\n",
"`poc/site-1/`.\n",
"\n",
"To prevent repeatedly downloading the dataset, you can copy the uncompressed `Task09_Spleen` into the corresponding place after running the `deploy_app` command.\n",
"For example:\n",
"If you already have the `Task09_Spleen`, you can copy it into the corresponding place directly to prevent repeatedly download. For example:\n",
"\n",
"```\n",
"cp -r /path-to-dataset/Task09_Spleen poc/site-1/run_2/app_site-1/\n",
"cp -r /path-to-dataset/Task09_Spleen poc/site-1/\n",
"```"
]
},
Expand Down
8 changes: 5 additions & 3 deletions federated_learning/nvflare/nvflare_spleen_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

## Brief Introduction

This repository contains an end-to-end Federated training example based on MONAI trainers and [NVIDIA FLARE](https://github.com/nvidia/nvflare).
This repository contains an end-to-end Federated training example based on MONAI trainers and [NVIDIA FLARE](https://github.com/nvidia/nvflare). Please also download the `hello-monai` folder in [NVFlare/examples](https://github.com/NVIDIA/NVFlare/tree/main/examples/hello-monai), and copy it into this directory.



This example requires Python 3.8.10

Inside this folder:
Inside this directory:
- All Jupiter notebooks are used to build an FL experiment step-by-step.
- `hello-monai` is a folder containing all required config files for the experiment (in `config/`) and the customized trainer (in `custom`) and its components.
- hello-monai (needs to be downloaded) is a folder containing all required config files for the experiment (in `config/`) and the customized trainer (in `custom`) and its components.

## Installation

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading