Skip to content

Commit 55a6ad2

Browse files
update example with nvflare 2.0.2 (#474)
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
1 parent 1c05d9e commit 55a6ad2

File tree

10 files changed

+25
-737
lines changed

10 files changed

+25
-737
lines changed

federated_learning/nvflare/nvflare_spleen_example/3-Admin.ipynb

Lines changed: 19 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
{
2929
"cell_type": "code",
30-
"execution_count": 1,
30+
"execution_count": null,
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
@@ -46,17 +46,9 @@
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": 2,
49+
"execution_count": null,
5050
"metadata": {},
51-
"outputs": [
52-
{
53-
"name": "stdout",
54-
"output_type": "stream",
55-
"text": [
56-
"a working folder for the admin exists!!!\n"
57-
]
58-
}
59-
],
51+
"outputs": [],
6052
"source": [
6153
"admin_path = \"poc/admin/startup/\"\n",
6254
"\n",
@@ -73,50 +65,28 @@
7365
},
7466
{
7567
"cell_type": "code",
76-
"execution_count": 3,
68+
"execution_count": null,
7769
"metadata": {},
7870
"outputs": [],
7971
"source": [
8072
"!mkdir -p poc/admin/transfer\n",
81-
"!cp -r hello_monai/ poc/admin/transfer/"
73+
"!cp -r hello-monai/ poc/admin/transfer/"
8274
]
8375
},
8476
{
8577
"cell_type": "code",
86-
"execution_count": 4,
78+
"execution_count": null,
8779
"metadata": {},
88-
"outputs": [
89-
{
90-
"data": {
91-
"text/plain": [
92-
"['hello_monai']"
93-
]
94-
},
95-
"execution_count": 4,
96-
"metadata": {},
97-
"output_type": "execute_result"
98-
}
99-
],
80+
"outputs": [],
10081
"source": [
10182
"os.listdir(\"poc/admin/transfer/\")"
10283
]
10384
},
10485
{
10586
"cell_type": "code",
106-
"execution_count": 5,
87+
"execution_count": null,
10788
"metadata": {},
108-
"outputs": [
109-
{
110-
"data": {
111-
"text/plain": [
112-
"['fl_admin.sh']"
113-
]
114-
},
115-
"execution_count": 5,
116-
"metadata": {},
117-
"output_type": "execute_result"
118-
}
119-
],
89+
"outputs": [],
12090
"source": [
12191
"os.listdir(admin_path)"
12292
]
@@ -144,23 +114,9 @@
144114
},
145115
{
146116
"cell_type": "code",
147-
"execution_count": 6,
117+
"execution_count": null,
148118
"metadata": {},
149-
"outputs": [
150-
{
151-
"data": {
152-
"text/html": [
153-
"<a href=\"\", data-commandlinker-command=\"terminal:create-new\"> Open a new terminal</a>"
154-
],
155-
"text/plain": [
156-
"<IPython.core.display.HTML object>"
157-
]
158-
},
159-
"execution_count": 6,
160-
"metadata": {},
161-
"output_type": "execute_result"
162-
}
163-
],
119+
"outputs": [],
164120
"source": [
165121
"HTML('<a href=\"\", data-commandlinker-command=\"terminal:create-new\"> Open a new terminal</a>')"
166122
]
@@ -192,51 +148,18 @@
192148
"\n",
193149
"The commands can be:\n",
194150
"```\n",
195-
"upload_app hello_monai\n",
151+
"upload_app hello-monai\n",
196152
"set_run_number 1\n",
197-
"deploy_app hello_monai server\n",
198-
"deploy_app hello_monai client\n",
199-
"```\n",
200-
"\n",
201-
"Now, let's check if the folder has been distributed into the server and all client(s):"
202-
]
203-
},
204-
{
205-
"cell_type": "code",
206-
"execution_count": 7,
207-
"metadata": {},
208-
"outputs": [
209-
{
210-
"name": "stdout",
211-
"output_type": "stream",
212-
"text": [
213-
"config files on server: ['app_server', 'fl_app.txt']\n",
214-
" \n",
215-
"config files on site-1: ['app_site-1', 'fl_app.txt']\n",
216-
" \n",
217-
"config files on site-2: ['fl_app.txt', 'app_site-2']\n",
218-
" \n"
219-
]
220-
}
221-
],
222-
"source": [
223-
"run_file = \"run_1\"\n",
224-
"\n",
225-
"poc_path = \"poc/\"\n",
226-
"\n",
227-
"for name in [\"server\", \"site-1\", \"site-2\"]:\n",
228-
" path = os.path.join(poc_path, name, run_file)\n",
229-
" if os.path.exists(path):\n",
230-
" print(\"config files on {}: {}\".\n",
231-
" format(name, os.listdir(path)))\n",
232-
" print(\" \")"
153+
"deploy_app hello-monai server\n",
154+
"deploy_app hello-monai client\n",
155+
"```"
233156
]
234157
},
235158
{
236159
"cell_type": "markdown",
237160
"metadata": {},
238161
"source": [
239-
"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",
162+
"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",
240163
"\n",
241164
"[Link to site-1 config](poc/site-1/run_1/app_site-1/config/config_train.json)\n",
242165
"\n",
@@ -250,13 +173,12 @@
250173
"### (Optional) Copy Dataset\n",
251174
"\n",
252175
"After starting a client (for example `site-1`), the Spleen dataset will be downloaded into:\n",
253-
"`run_1/app_site-1/Task09_Spleen.tar`.\n",
176+
"`poc/site-1/`.\n",
254177
"\n",
255-
"To prevent repeatedly downloading the dataset, you can copy the uncompressed `Task09_Spleen` into the corresponding place after running the `deploy_app` command.\n",
256-
"For example:\n",
178+
"If you already have the `Task09_Spleen`, you can copy it into the corresponding place directly to prevent repeatedly download. For example:\n",
257179
"\n",
258180
"```\n",
259-
"cp -r /path-to-dataset/Task09_Spleen poc/site-1/run_2/app_site-1/\n",
181+
"cp -r /path-to-dataset/Task09_Spleen poc/site-1/\n",
260182
"```"
261183
]
262184
},

federated_learning/nvflare/nvflare_spleen_example/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
## Brief Introduction
44

5-
This repository contains an end-to-end Federated training example based on MONAI trainers and [NVIDIA FLARE](https://github.com/nvidia/nvflare).
5+
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.
6+
7+
68

79
This example requires Python 3.8.10
810

9-
Inside this folder:
11+
Inside this directory:
1012
- All Jupiter notebooks are used to build an FL experiment step-by-step.
11-
- `hello-monai` is a folder containing all required config files for the experiment (in `config/`) and the customized trainer (in `custom`) and its components.
13+
- 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.
1214

1315
## Installation
1416

federated_learning/nvflare/nvflare_spleen_example/hello_monai/config/config_fed_client.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

federated_learning/nvflare/nvflare_spleen_example/hello_monai/config/config_fed_server.json

Lines changed: 0 additions & 63 deletions
This file was deleted.

federated_learning/nvflare/nvflare_spleen_example/hello_monai/config/config_train.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

federated_learning/nvflare/nvflare_spleen_example/hello_monai/config/dataset_part1.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

federated_learning/nvflare/nvflare_spleen_example/hello_monai/config/dataset_part2.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)