Skip to content

Commit

Permalink
updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq committed Dec 19, 2023
1 parent 099f6cf commit b5280f8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion doc/source/example-jax-from-centralized-to-federated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Having defined the federation process, we can run it.
# Start Flower client
client = FlowerClient(params, grad_fn, train_x, train_y, test_x, test_y)
fl.client.start_numpy_client(server_address="0.0.0.0:8080", client)
fl.client.start_client(server_address="0.0.0.0:8080", client.to_client())
if __name__ == "__main__":
main()
Expand Down
4 changes: 2 additions & 2 deletions doc/source/example-pytorch-from-centralized-to-federated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ We included type annotations to give you a better understanding of the data type
return float(loss), self.num_examples["testset"], {"accuracy": float(accuracy)}
All that's left to do it to define a function that loads both model and data, creates a :code:`CifarClient`, and starts this client.
You load your data and model by using :code:`cifar.py`. Start :code:`CifarClient` with the function :code:`fl.client.start_numpy_client()` by pointing it at the same IP adress we used in :code:`server.py`:
You load your data and model by using :code:`cifar.py`. Start :code:`CifarClient` with the function :code:`fl.client.start_client()` by pointing it at the same IP adress we used in :code:`server.py`:

.. code-block:: python
Expand All @@ -292,7 +292,7 @@ You load your data and model by using :code:`cifar.py`. Start :code:`CifarClient
# Start client
client = CifarClient(model, trainloader, testloader, num_examples)
fl.client.start_numpy_client(server_address="0.0.0.0:8080", client)
fl.client.start_client(server_address="0.0.0.0:8080", client.to_client())
if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion doc/source/how-to-run-simulations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Run simulations

Simulating Federated Learning workloads is useful for a multitude of use-cases: you might want to run your workload on a large cohort of clients but without having to source, configure and mange a large number of physical devices; you might want to run your FL workloads as fast as possible on the compute systems you have access to without having to go through a complex setup process; you might want to validate your algorithm on different scenarios at varying levels of data and system heterogeneity, client availability, privacy budgets, etc. These are among some of the use-cases where simulating FL workloads makes sense. Flower can accommodate these scenarios by means of its `VirtualClientEngine <contributor-explanation-architecture.html#virtual-client-engine>`_ or VCE.

The :code:`VirtualClientEngine` schedules, launches and manages `virtual` clients. These clients are identical to `non-virtual` clients (i.e. the ones you launch via the command `flwr.client.start_numpy_client <ref-api-flwr.html#start-numpy-client>`_) in the sense that they can be configure by creating a class inheriting, for example, from `flwr.client.NumPyClient <ref-api-flwr.html#flwr.client.NumPyClient>`_ and therefore behave in an identical way. In addition to that, clients managed by the :code:`VirtualClientEngine` are:
The :code:`VirtualClientEngine` schedules, launches and manages `virtual` clients. These clients are identical to `non-virtual` clients (i.e. the ones you launch via the command `flwr.client.start_client <ref-api-flwr.html#start-client>`_) in the sense that they can be configure by creating a class inheriting, for example, from `flwr.client.NumPyClient <ref-api-flwr.html#flwr.client.NumPyClient>`_ and therefore behave in an identical way. In addition to that, clients managed by the :code:`VirtualClientEngine` are:

* resource-aware: this means that each client gets assigned a portion of the compute and memory on your system. You as a user can control this at the beginning of the simulation and allows you to control the degree of parallelism of your Flower FL simulation. The fewer the resources per client, the more clients can run concurrently on the same hardware.
* self-managed: this means that you as a user do not need to launch clients manually, instead this gets delegated to :code:`VirtualClientEngine`'s internals.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial-quickstart-huggingface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ We can now start client instances using:

.. code-block:: python
fl.client.start_numpy_client(
fl.client.start_client(
server_address="127.0.0.1:8080",
client=IMDBClient()
client=IMDBClient().to_client()
)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/tutorial-quickstart-jax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Having defined the federation process, we can run it.
# Start Flower client
client = FlowerClient(params, grad_fn, train_x, train_y, test_x, test_y)
fl.client.start_numpy_client(server_address="0.0.0.0:8080", client)
fl.client.start_client(server_address="0.0.0.0:8080", client=client.to_client())
if __name__ == "__main__":
main()
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial-quickstart-pytorch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ to actually run this client:

.. code-block:: python
fl.client.start_numpy_client(server_address="[::]:8080", client=CifarClient())
fl.client.start_client(server_address="[::]:8080", client=CifarClient())
That's it for the client. We only have to implement :code:`Client` or
:code:`NumPyClient` and call :code:`fl.client.start_client()` or :code:`fl.client.start_numpy_client()`. The string :code:`"[::]:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`NumPyClient` and call :code:`fl.client.start_client()`. If you implement a client of type :code:`NumPyClient` you'll need to first call its :code:`to_client()` method. The string :code:`"[::]:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`"[::]:8080"`. If we run a truly federated workload with the server and
clients running on different machines, all that needs to change is the
:code:`server_address` we point the client at.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial-quickstart-scikitlearn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ to actually run this client:

.. code-block:: python
fl.client.start_numpy_client("0.0.0.0:8080", client=MnistClient())
fl.client.start_client("0.0.0.0:8080", client=MnistClient().to_client())
That's it for the client. We only have to implement :code:`Client` or
:code:`NumPyClient` and call :code:`fl.client.start_client()` or :code:`fl.client.start_numpy_client()`. The string :code:`"0.0.0.0:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`NumPyClient` and call :code:`fl.client.start_client()`. If you implement a client of type :code:`NumPyClient` you'll need to first call its :code:`to_client()` method. The string :code:`"0.0.0.0:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`"0.0.0.0:8080"`. If we run a truly federated workload with the server and
clients running on different machines, all that needs to change is the
:code:`server_address` we pass to the client.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial-quickstart-tensorflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ to actually run this client:

.. code-block:: python
fl.client.start_numpy_client(server_address="[::]:8080", client=CifarClient())
fl.client.start_client(server_address="[::]:8080", client=CifarClient().to_client())
That's it for the client. We only have to implement :code:`Client` or
:code:`NumPyClient` and call :code:`fl.client.start_client()` or :code:`fl.client.start_numpy_client()`. The string :code:`"[::]:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`NumPyClient` and call :code:`fl.client.start_client()`. If you implement a client of type :code:`NumPyClient` you'll need to first call its :code:`to_client()` method. The string :code:`"[::]:8080"` tells the client which server to connect to. In our case we can run the server and the client on the same machine, therefore we use
:code:`"[::]:8080"`. If we run a truly federated workload with the server and
clients running on different machines, all that needs to change is the
:code:`server_address` we point the client at.
Expand Down
13 changes: 9 additions & 4 deletions src/py/flwr/client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ def start_numpy_client(
) -> None:
"""Start a Flower NumPyClient which connects to a gRPC server.
.. deprecated:: 1.7.0
Use flwr.client.start_client() instead and pass your client of NumPyClient type
by first exectuing its .to_client method.
Parameters
----------
server_address : str
Expand Down Expand Up @@ -456,12 +460,13 @@ def start_numpy_client(
"""
warnings.warn(
"flwr.client.start_numpy_client() is deprecated and will "
"be removed in a future version of Flower. Instead, pass "
"your client to `flwr.client.start_client()` by calling "
"first the `.to_client()` method as shown below: \n"
"be removed in a future version of Flower. Instead, use "
"`flwr.client.start_client()` by ensuring you first call "
"the `.to_client()` method as shown below: \n"
"\tflwr.client.start_client(\n"
"\t\tserver_address='<IP>:<PORT>',\n"
"\t\tclient=FlowerClient().to_client()\n"
"\t\tclient=FlowerClient().to_client(),"
" # <-- where FlowerClient is of type flwr.client.NumPyClient object\n"
"\t)",
DeprecationWarning,
stacklevel=2,
Expand Down

0 comments on commit b5280f8

Please sign in to comment.