Skip to content
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

Docs/SK-796 | Update flower readme #582

Merged
merged 6 commits into from
Apr 18, 2024
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
51 changes: 34 additions & 17 deletions examples/flower-client/README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Using Flower ClientApps in FEDn
-------------------------------
FEDn Project: Flower ClientApps in FEDn
---------------------------------------

This example demonstrates how to run a Flower 'ClientApp' on FEDn.

The FEDn compute package 'client/entrypoint'
uses a built-in Flower compatibiltiy adapter for convenient wrapping of the Flower client.
See `flwr_client.py` and `flwr_task.py` for the Flower client code (which is adapted from
https://github.com/adap/flower/tree/main/examples/app-pytorch).
https://github.com/adap/flower/tree/main/examples/app-pytorch).


Running the example
Expand Down Expand Up @@ -42,29 +42,27 @@ Next, generate a seed model (the first model in the global model trail):

fedn run build --path client

Next, you will upload the compute package and seed model to
This creates a seed.npz in the root of the project folder. Next, you will upload the compute package and seed model to
a FEDn network. Here you have two main options: using FEDn Studio
(recommended for new users), or a pseudo-local deployment
(recommended for new users), or a self-managed pseudo-distributed deployment
on your own machine.

If you are using FEDn Studio (recommended):
-----------------------------------------------------
-------------------------------------------

Follow instructions here to register for Studio and start a project: https://fedn.readthedocs.io/en/stable/studio.html.

In your Studio project:

- From the "Sessions" menu, upload the compute package and seed model.
- From the "Sessions" menu, upload the compute package (package.tgz) and seed model (seed.npz).
- Register a client and obtain the corresponding 'client.yaml'.

On your local machine / client, start the FEDn client:


.. code-block::

export FEDN_AUTH_SCHEME=Bearer
export FEDN_PACKAGE_EXTRACT_DIR=package
CLIENT_NUMBER=0 fedn run client -in client.yaml --secure=True --force-ssl
fedn run client -in client.yaml --secure=True --force-ssl


Or, if you prefer to use Docker (this might take a long time):
Expand All @@ -74,15 +72,14 @@ Or, if you prefer to use Docker (this might take a long time):
docker run \
-v $PWD/client.yaml:/app/client.yaml \
-e CLIENT_NUMBER=0 \
-e FEDN_AUTH_SCHEME=Bearer \
-e FEDN_PACKAGE_EXTRACT_DIR=package \
ghcr.io/scaleoutsystems/fedn/fedn:master run client -in client.yaml --secure=True --force-ssl
ghcr.io/scaleoutsystems/fedn/fedn:0.9.0 run client -in client.yaml --secure=True --force-ssl


If you are running FEDn in pseudo-local mode:
------------------------------------------------------------------
If you are running FEDn in local development mode:
--------------------------------------------------

Deploy a FEDn network on local host (see `https://fedn.readthedocs.io/en/stable/quickstart.html`).
Deploy a FEDn network on local host (see `https://fedn.readthedocs.io/en/stable/quickstart.html#local-development-deployment-using-docker-compose`).

Use the FEDn API Client to initalize FEDn with the compute package and seed model:

Expand All @@ -107,6 +104,26 @@ Then start the client (using Docker)
-v $PWD/client.yaml:/app/client.yaml \
--network=fedn_default \
-e CLIENT_NUMBER=0 \
-e FEDN_AUTH_SCHEME=Bearer \
-e FEDN_PACKAGE_EXTRACT_DIR=package \
ghcr.io/scaleoutsystems/fedn/fedn:master run client -in client.yaml
ghcr.io/scaleoutsystems/fedn/fedn:0.9.0 run client -in client.yaml


Scaling to multiple clients
------------------------------------------------------------------

To scale the experiment with additional clients on the same host, execute the run command
again from another terminal. If running from another host, add another 'client.yaml', install
fedn, and execute the run command. In both cases inject a client number as an environment
varible which is used for distributing data (see 'flwr_task.py').

For Unix Operating Systems:

.. code-block::

CLIENT_NUMBER=0 fedn run client -in client.yaml --secure=True --force-ssl

Using Windows PowerShell:

.. code-block::

& { $env:CLIENT_NUMBER="0"; fedn run client -in client.yaml --secure=$true --force-ssl }
2 changes: 1 addition & 1 deletion examples/flower-client/client/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def save_parameters(out_path, parameters_np):
helper.save(parameters_np, out_path)


def init_seed(out_path="seed.npz"):
def init_seed(out_path="../seed.npz"):
"""Initialize seed model and save it to file.

:param out_path: The path to save the seed model to.
Expand Down
Loading