Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
192 changes: 192 additions & 0 deletions federated_learning/nvflare/1-Server.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"metadata": false
}
},
"source": [
"# FL Server Joining FL experiment\n",
"\n",
"The purpose of this notebook is to show how to start a server to participate in an FL experiment."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from IPython.display import HTML"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Check Working Folder\n",
"\n",
"Before starting, let's check if the necessary folder is created:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a working folder for the server exists!!!\n"
]
}
],
"source": [
"server_startup_path = \"poc/server/startup\"\n",
"\n",
"if os.path.exists(server_startup_path):\n",
" print(\"a working folder for the server exists!!!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then, let's check the catalogue:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['log.config', 'fed_server.json', 'sub_start.sh', 'start.sh', 'stop_fl.sh']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.listdir(server_startup_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, a script named `start.sh` is in the path, to start a server, we only need to run this script."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Start Server"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Please open a new terminal (please run the following cell and click the link):"
]
},
{
"cell_type": "code",
"execution_count": 4,
"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": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# You can click the following link, or manually open a new terminal.\n",
"HTML('<a href=\"\", data-commandlinker-command=\"terminal:create-new\"> Open a new terminal</a>')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the terminal, please run the following command:\n",
"```\n",
"source nvflare-env/bin/activate\n",
"bash poc/server/startup/start.sh\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### (Optional) Close Server\n",
"\n",
"Except using admin, you can close the started server directly via run the following command:\n",
"\n",
"```\n",
"bash poc/server/startup/stop_fl.sh\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Next Steps\n",
"\n",
"You have now started the server container.\n",
"In the next notebook, [Client Startup Notebook](2-Client.ipynb), you'll start two clients participating in the FL experiment."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"stem_cell": {
"cell_type": "raw",
"metadata": {
"pycharm": {
"metadata": false
}
},
"source": ""
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading