From 304b196a9690512183120e476a56b1cc669a156c Mon Sep 17 00:00:00 2001 From: jafermarq Date: Mon, 6 Nov 2023 13:37:52 +0000 Subject: [PATCH 01/16] added deprecated warning back --- doc/source/ref-changelog.md | 2 +- src/py/flwr/client/app.py | 25 ++++++++++--------- src/py/flwr/simulation/ray_transport/utils.py | 21 ++++++++-------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/doc/source/ref-changelog.md b/doc/source/ref-changelog.md index 03ef01c0234b..8429bdd7270a 100644 --- a/doc/source/ref-changelog.md +++ b/doc/source/ref-changelog.md @@ -48,7 +48,7 @@ - **General updates to the simulation engine** ([#2331](https://github.com/adap/flower/pull/2331), [#2447](https://github.com/adap/flower/pull/2447), [#2448](https://github.com/adap/flower/pull/2448)) -- **General improvements** ([#2309](https://github.com/adap/flower/pull/2309), [#2310](https://github.com/adap/flower/pull/2310), [2313](https://github.com/adap/flower/pull/2313), [#2316](https://github.com/adap/flower/pull/2316), [2317](https://github.com/adap/flower/pull/2317),[#2349](https://github.com/adap/flower/pull/2349), [#2360](https://github.com/adap/flower/pull/2360), [#2402](https://github.com/adap/flower/pull/2402), [#2446](https://github.com/adap/flower/pull/2446) [#2561](https://github.com/adap/flower/pull/2561)) +- **General improvements** ([#2309](https://github.com/adap/flower/pull/2309), [#2310](https://github.com/adap/flower/pull/2310), [2313](https://github.com/adap/flower/pull/2313), [#2316](https://github.com/adap/flower/pull/2316), [2317](https://github.com/adap/flower/pull/2317),[#2349](https://github.com/adap/flower/pull/2349), [#2360](https://github.com/adap/flower/pull/2360), [#2402](https://github.com/adap/flower/pull/2402), [#2446](https://github.com/adap/flower/pull/2446), [#2561](https://github.com/adap/flower/pull/2561), [#2562](https://github.com/adap/flower/pull/2562)) Flower received many improvements under the hood, too many to list here. diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 56f1b7c04144..6c104ea952d8 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -17,6 +17,7 @@ import sys import time +import warnings from logging import INFO from typing import Callable, ContextManager, Optional, Tuple, Union @@ -238,18 +239,18 @@ def start_numpy_client( >>> root_certificates=Path("/crts/root.pem").read_bytes(), >>> ) """ - # 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" - # "\tflwr.client.start_client(\n" - # "\t\tserver_address=':',\n" - # "\t\tclient=FlowerClient().to_client()\n" - # "\t)", - # DeprecationWarning, - # stacklevel=2, - # ) + 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" + "\tflwr.client.start_client(\n" + "\t\tserver_address=':',\n" + "\t\tclient=FlowerClient().to_client()\n" + "\t)", + DeprecationWarning, + stacklevel=2, + ) # Calling this function is deprecated. A warning is thrown. # We first need to convert either the supplied client to `Client.` diff --git a/src/py/flwr/simulation/ray_transport/utils.py b/src/py/flwr/simulation/ray_transport/utils.py index c8e6aa6cbe21..01e2257b429e 100644 --- a/src/py/flwr/simulation/ray_transport/utils.py +++ b/src/py/flwr/simulation/ray_transport/utils.py @@ -15,6 +15,7 @@ """Utilities for Actors in the Virtual Client Engine.""" import traceback +import warnings from logging import ERROR from flwr.client import Client @@ -26,7 +27,7 @@ TF = None # Display Deprecation warning once -# warnings.filterwarnings("once", category=DeprecationWarning) +warnings.filterwarnings("once", category=DeprecationWarning) def enable_tf_gpu_growth() -> None: @@ -69,15 +70,15 @@ def check_clientfn_returns_client(client: Client) -> Client: the client internally to `Client` by calling `.to_client()`. """ if not isinstance(client, Client): - # mssg = ( - # " Ensure your client is of type `Client`. Please convert it" - # " using the `.to_client()` method before returning it" - # " in the `client_fn` you pass to `start_simulation`." - # " We have applied this conversion on your behalf." - # " Not returning a `Client` might trigger an error in future" - # " versions of Flower." - # ) + mssg = ( + " Ensure your client is of type `Client`. Please convert it" + " using the `.to_client()` method before returning it" + " in the `client_fn` you pass to `start_simulation`." + " We have applied this conversion on your behalf." + " Not returning a `Client` might trigger an error in future" + " versions of Flower." + ) - # warnings.warn(mssg, DeprecationWarning, stacklevel=2) + warnings.warn(mssg, DeprecationWarning, stacklevel=2) client = client.to_client() return client From b5280f862b635fe1688838f35127f418f6b3c299 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Tue, 19 Dec 2023 23:23:52 +0100 Subject: [PATCH 02/16] updating docs --- .../example-jax-from-centralized-to-federated.rst | 2 +- ...xample-pytorch-from-centralized-to-federated.rst | 4 ++-- doc/source/how-to-run-simulations.rst | 2 +- doc/source/tutorial-quickstart-huggingface.rst | 4 ++-- doc/source/tutorial-quickstart-jax.rst | 2 +- doc/source/tutorial-quickstart-pytorch.rst | 4 ++-- doc/source/tutorial-quickstart-scikitlearn.rst | 4 ++-- doc/source/tutorial-quickstart-tensorflow.rst | 4 ++-- src/py/flwr/client/app.py | 13 +++++++++---- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/source/example-jax-from-centralized-to-federated.rst b/doc/source/example-jax-from-centralized-to-federated.rst index 2b1823e9d408..6b06a288a67a 100644 --- a/doc/source/example-jax-from-centralized-to-federated.rst +++ b/doc/source/example-jax-from-centralized-to-federated.rst @@ -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() diff --git a/doc/source/example-pytorch-from-centralized-to-federated.rst b/doc/source/example-pytorch-from-centralized-to-federated.rst index d649658667da..58101135b8c0 100644 --- a/doc/source/example-pytorch-from-centralized-to-federated.rst +++ b/doc/source/example-pytorch-from-centralized-to-federated.rst @@ -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 @@ -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__": diff --git a/doc/source/how-to-run-simulations.rst b/doc/source/how-to-run-simulations.rst index 707e3d3ffe84..6e0520a79bf5 100644 --- a/doc/source/how-to-run-simulations.rst +++ b/doc/source/how-to-run-simulations.rst @@ -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 `_ 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 `_) in the sense that they can be configure by creating a class inheriting, for example, from `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 `_) in the sense that they can be configure by creating a class inheriting, for example, from `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. diff --git a/doc/source/tutorial-quickstart-huggingface.rst b/doc/source/tutorial-quickstart-huggingface.rst index 7718e6558456..1e06120b452f 100644 --- a/doc/source/tutorial-quickstart-huggingface.rst +++ b/doc/source/tutorial-quickstart-huggingface.rst @@ -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() ) diff --git a/doc/source/tutorial-quickstart-jax.rst b/doc/source/tutorial-quickstart-jax.rst index 945f231e112e..d2b9243e2bb3 100644 --- a/doc/source/tutorial-quickstart-jax.rst +++ b/doc/source/tutorial-quickstart-jax.rst @@ -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() diff --git a/doc/source/tutorial-quickstart-pytorch.rst b/doc/source/tutorial-quickstart-pytorch.rst index fb77d107b63f..c1068253f2d9 100644 --- a/doc/source/tutorial-quickstart-pytorch.rst +++ b/doc/source/tutorial-quickstart-pytorch.rst @@ -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. diff --git a/doc/source/tutorial-quickstart-scikitlearn.rst b/doc/source/tutorial-quickstart-scikitlearn.rst index b33068e975fa..4921f63bab2c 100644 --- a/doc/source/tutorial-quickstart-scikitlearn.rst +++ b/doc/source/tutorial-quickstart-scikitlearn.rst @@ -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. diff --git a/doc/source/tutorial-quickstart-tensorflow.rst b/doc/source/tutorial-quickstart-tensorflow.rst index 64b2255a9ac6..bd63eb461d21 100644 --- a/doc/source/tutorial-quickstart-tensorflow.rst +++ b/doc/source/tutorial-quickstart-tensorflow.rst @@ -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. diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 7db651a8fc1b..cb38cc5146b5 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -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 @@ -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=':',\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, From dfd1ba49f2b9ac135aa7bc51dfb5c871e20acba7 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Tue, 19 Dec 2023 23:26:25 +0100 Subject: [PATCH 03/16] format --- src/py/flwr/client/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index cb38cc5146b5..0005f511e086 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -400,6 +400,7 @@ def start_numpy_client( """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. @@ -465,7 +466,7 @@ def start_numpy_client( "the `.to_client()` method as shown below: \n" "\tflwr.client.start_client(\n" "\t\tserver_address=':',\n" - "\t\tclient=FlowerClient().to_client()," + "\t\tclient=FlowerClient().to_client()," " # <-- where FlowerClient is of type flwr.client.NumPyClient object\n" "\t)", DeprecationWarning, From 24cf3a09bed1cca2410c51b29587e3f372b09b23 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Wed, 20 Dec 2023 10:08:57 +0100 Subject: [PATCH 04/16] better --- src/py/flwr/client/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 0005f511e086..578571d0787a 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -399,10 +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. + .. warning:: + This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` + instead and pass your client of type :code:`flwr.client.NumPyClient` by first + exectuing its :code:`.to_client()` method. Parameters ---------- From f0ac9563f25f7bf3d6b8ba0888b8af16246d0d16 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Wed, 20 Dec 2023 10:11:23 +0100 Subject: [PATCH 05/16] howto ssl --- doc/source/how-to-enable-ssl-connections.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/how-to-enable-ssl-connections.rst b/doc/source/how-to-enable-ssl-connections.rst index fa59d4423c5a..051dd5711497 100644 --- a/doc/source/how-to-enable-ssl-connections.rst +++ b/doc/source/how-to-enable-ssl-connections.rst @@ -75,9 +75,9 @@ We are now going to show how to write a client which uses the previously generat client = MyFlowerClient() # Start client - fl.client.start_numpy_client( + fl.client.start_client( "localhost:8080", - client=client, + client=client.to_client(), root_certificates=Path(".cache/certificates/ca.crt").read_bytes(), ) From 25063a5eb4eaf46be0ff9fd62e47da85023e5921 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Wed, 20 Dec 2023 10:17:50 +0100 Subject: [PATCH 06/16] to changelog --- doc/source/ref-changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/ref-changelog.md b/doc/source/ref-changelog.md index 603e6c602274..fa2f6662fb31 100644 --- a/doc/source/ref-changelog.md +++ b/doc/source/ref-changelog.md @@ -10,6 +10,8 @@ - FedVSSL [#2412](https://github.com/adap/flower/pull/2412) +- **Deprecated `start_numpy_client`**. ([#2563](https://github.com/adap/flower/pull/2563)) Until now, clients of type `NumPyClient` needed to be started via `start_numpy_client`. In our efforts to consolidate the core freamework we have introduced changes and now all client types should start via `start_client`. To continue using `NumPyClient` clients, you simply need to first all the `.to_client()` method then pass the client object to `start_client`. The examples and the documentation have been updated accordigntly. + ## v1.6.0 (2023-11-28) ### Thanks to our contributors From bb6b2530338317370eae29afd97bcd7607478a12 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Mon, 29 Jan 2024 09:22:21 +0000 Subject: [PATCH 07/16] using new deprecation logger func --- src/py/flwr/client/app.py | 17 ++++++++--------- src/py/flwr/simulation/ray_transport/utils.py | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index b99b5cc518cc..611a6fa6a797 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -18,7 +18,6 @@ import argparse import sys import time -import warnings from logging import INFO, WARN from pathlib import Path from typing import Callable, ContextManager, Optional, Tuple, Union @@ -35,7 +34,7 @@ TRANSPORT_TYPE_REST, TRANSPORT_TYPES, ) -from flwr.common.logger import log, warn_experimental_feature +from flwr.common.logger import log, warn_deprecated_feature, warn_experimental_feature from flwr.proto.task_pb2 import TaskIns, TaskRes # pylint: disable=E0611 from .flower import load_flower_callable @@ -461,22 +460,22 @@ def start_numpy_client( >>> root_certificates=Path("/crts/root.pem").read_bytes(), >>> ) """ - warnings.warn( - "flwr.client.start_numpy_client() is deprecated and will " - "be removed in a future version of Flower. Instead, use " + mssg = ( + "flwr.client.start_numpy_client() is deprecated. \n\tInstead, 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=':',\n" "\t\tclient=FlowerClient().to_client()," " # <-- where FlowerClient is of type flwr.client.NumPyClient object\n" - "\t)", - DeprecationWarning, - stacklevel=2, + "\t)\n" + "\tUsing `start_numpy_client()` is deprecated." ) + warn_deprecated_feature(name=mssg) + # Calling this function is deprecated. A warning is thrown. - # We first need to convert either the supplied client to `Client.` + # We first need to convert the supplied client to `Client.` wrp_client = client.to_client() diff --git a/src/py/flwr/simulation/ray_transport/utils.py b/src/py/flwr/simulation/ray_transport/utils.py index a60c79409b01..dd9fb6b2aa85 100644 --- a/src/py/flwr/simulation/ray_transport/utils.py +++ b/src/py/flwr/simulation/ray_transport/utils.py @@ -71,7 +71,7 @@ def check_clientfn_returns_client(client: Client) -> Client: """ if not isinstance(client, Client): mssg = ( - " Ensure your client is of type `Client`. Please convert it" + " Ensure your client is of type `flwr.client.Client`. Please convert it" " using the `.to_client()` method before returning it" " in the `client_fn` you pass to `start_simulation`." " We have applied this conversion on your behalf." From d06ddd247aa94eb2a7855837b059828c62d31671 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Mon, 29 Jan 2024 09:47:53 +0000 Subject: [PATCH 08/16] better docs --- src/py/flwr/client/app.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 611a6fa6a797..23c6f9f925e0 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -400,10 +400,11 @@ def start_numpy_client( ) -> None: """Start a Flower NumPyClient which connects to a gRPC server. - .. warning:: - This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` - instead and pass your client of type :code:`flwr.client.NumPyClient` by first - exectuing its :code:`.to_client()` method. + Warning + ------- + This function is deprecated since 1.7.0. Use `start_client ` + instead and first convert your client to type :code:`flwr.client.Client` by + exectuing its `to_client() Date: Mon, 29 Jan 2024 11:11:43 +0000 Subject: [PATCH 09/16] revert --- src/py/flwr/client/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 23c6f9f925e0..f762b37ca4e9 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -402,9 +402,9 @@ def start_numpy_client( Warning ------- - This function is deprecated since 1.7.0. Use `start_client ` + This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` instead and first convert your client to type :code:`flwr.client.Client` by - exectuing its `to_client() Date: Mon, 29 Jan 2024 20:55:10 +0000 Subject: [PATCH 10/16] no start_numpy_client --- e2e/bare-https/client.py | 4 ++-- e2e/bare/client.py | 2 +- e2e/fastai/client.py | 4 ++-- e2e/jax/client.py | 2 +- e2e/opacus/client.py | 4 ++-- e2e/pandas/client.py | 4 ++-- e2e/pytorch-lightning/client.py | 4 ++-- e2e/pytorch/client.py | 4 ++-- e2e/scikit-learn/client.py | 2 +- e2e/strategies/client.py | 2 +- e2e/tabnet/client.py | 2 +- e2e/tensorflow/client.py | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/e2e/bare-https/client.py b/e2e/bare-https/client.py index 20a5b4875ddf..04563acdd73f 100644 --- a/e2e/bare-https/client.py +++ b/e2e/bare-https/client.py @@ -31,9 +31,9 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client( + fl.client.start_client( server_address="127.0.0.1:8080", - client=FlowerClient(), + client=FlowerClient().to_client(), root_certificates=Path("certificates/ca.crt").read_bytes(), insecure=False, ) diff --git a/e2e/bare/client.py b/e2e/bare/client.py index 59ef2e4248ee..1068bd7da6d1 100644 --- a/e2e/bare/client.py +++ b/e2e/bare/client.py @@ -52,4 +52,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=FlowerClient()) + fl.client.start_client(server_address="127.0.0.1:8080", client=FlowerClient().to_client()) diff --git a/e2e/fastai/client.py b/e2e/fastai/client.py index 4425fed25277..69b20f7e26c3 100644 --- a/e2e/fastai/client.py +++ b/e2e/fastai/client.py @@ -60,7 +60,7 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client( + fl.client.start_client( server_address="127.0.0.1:8080", - client=FlowerClient(), + client=FlowerClient().to_client(), ) diff --git a/e2e/jax/client.py b/e2e/jax/client.py index 495d6a671981..1536487dd466 100644 --- a/e2e/jax/client.py +++ b/e2e/jax/client.py @@ -59,4 +59,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=FlowerClient()) + fl.client.start_client(server_address="127.0.0.1:8080", client=FlowerClient().to_client()) diff --git a/e2e/opacus/client.py b/e2e/opacus/client.py index 2e5c363381fa..205bc39adbac 100644 --- a/e2e/opacus/client.py +++ b/e2e/opacus/client.py @@ -142,7 +142,7 @@ def client_fn(cid): ) if __name__ == "__main__": - fl.client.start_numpy_client( + fl.client.start_client( server_address="127.0.0.1:8080", - client=FlowerClient(model) + client=FlowerClient(model).to_client() ) diff --git a/e2e/pandas/client.py b/e2e/pandas/client.py index 5b8670091cb3..efc2eb763f53 100644 --- a/e2e/pandas/client.py +++ b/e2e/pandas/client.py @@ -42,7 +42,7 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client( + fl.client.start_client( server_address="127.0.0.1:8080", - client=FlowerClient(), + client=FlowerClient().to_client(), ) diff --git a/e2e/pytorch-lightning/client.py b/e2e/pytorch-lightning/client.py index 71b178eca8c3..632683e8ec01 100644 --- a/e2e/pytorch-lightning/client.py +++ b/e2e/pytorch-lightning/client.py @@ -65,8 +65,8 @@ def main() -> None: train_loader, val_loader, test_loader = mnist.load_data() # Flower client - client = FlowerClient(model, train_loader, val_loader, test_loader) - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=client) + client = FlowerClient(model, train_loader, val_loader, test_loader).to_client() + fl.client.start_client(server_address="127.0.0.1:8080", client=client) if __name__ == "__main__": diff --git a/e2e/pytorch/client.py b/e2e/pytorch/client.py index ccd36f47d22a..cce4701ff6e6 100644 --- a/e2e/pytorch/client.py +++ b/e2e/pytorch/client.py @@ -133,7 +133,7 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client( + fl.client.start_client( server_address="127.0.0.1:8080", - client=FlowerClient(), + client=FlowerClient().to_client(), ) diff --git a/e2e/scikit-learn/client.py b/e2e/scikit-learn/client.py index fdca96c1697a..e137a28c356b 100644 --- a/e2e/scikit-learn/client.py +++ b/e2e/scikit-learn/client.py @@ -52,4 +52,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="0.0.0.0:8080", client=FlowerClient()) + fl.client.start_client(server_address="0.0.0.0:8080", client=FlowerClient().to_client()) diff --git a/e2e/strategies/client.py b/e2e/strategies/client.py index eb4598cb5439..5a341d041f12 100644 --- a/e2e/strategies/client.py +++ b/e2e/strategies/client.py @@ -54,4 +54,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=FlowerClient()) + fl.client.start_client(server_address="127.0.0.1:8080", client=FlowerClient().to_client()) diff --git a/e2e/tabnet/client.py b/e2e/tabnet/client.py index 3c10df0c79f1..5e3a5e52680b 100644 --- a/e2e/tabnet/client.py +++ b/e2e/tabnet/client.py @@ -87,4 +87,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=FlowerClient()) + fl.client.start_client(server_address="127.0.0.1:8080", client=FlowerClient().to_client()) diff --git a/e2e/tensorflow/client.py b/e2e/tensorflow/client.py index 4ad2d5ebda57..fc5eb5ab39b3 100644 --- a/e2e/tensorflow/client.py +++ b/e2e/tensorflow/client.py @@ -40,4 +40,4 @@ def client_fn(cid): if __name__ == "__main__": # Start Flower client - fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=FlowerClient()) + fl.client.start_client(server_address="127.0.0.1:8080", client=FlowerClient().to_client()) From 07159904ed79e6a13ee579758ac55753473276a0 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Mon, 29 Jan 2024 21:03:57 +0000 Subject: [PATCH 11/16] format --- src/py/flwr/client/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index df7df7252e3d..7e31b799089d 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -34,7 +34,7 @@ TRANSPORT_TYPE_REST, TRANSPORT_TYPES, ) -from flwr.common.logger import log, warn_experimental_feature, warn_experimental_feature +from flwr.common.logger import log, warn_deprecated_feature, warn_experimental_feature from flwr.common.message import Message from .flower import load_flower_callable From 671f94129d8fbe8d6926a1775ea5be9d6cb80bed Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Tue, 30 Jan 2024 11:12:55 +0100 Subject: [PATCH 12/16] Update doc/source/ref-changelog.md --- doc/source/ref-changelog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/ref-changelog.md b/doc/source/ref-changelog.md index 26fb5dd0b70b..f1af015ac24c 100644 --- a/doc/source/ref-changelog.md +++ b/doc/source/ref-changelog.md @@ -8,7 +8,9 @@ - **Retiring MXNet examples** The development of the MXNet fremework has ended and the project is now [archived on GitHub](https://github.com/apache/mxnet). Existing MXNet examples won't receive updates [#2724](https://github.com/adap/flower/pull/2724) -- **Deprecated `start_numpy_client`**. ([#2563](https://github.com/adap/flower/pull/2563)) Until now, clients of type `NumPyClient` needed to be started via `start_numpy_client`. In our efforts to consolidate the core freamework we have introduced changes and now all client types should start via `start_client`. To continue using `NumPyClient` clients, you simply need to first all the `.to_client()` method then pass the client object to `start_client`. The examples and the documentation have been updated accordigntly. +- **Deprecated `start_numpy_client`**. ([#2563](https://github.com/adap/flower/pull/2563)) + + Until now, clients of type `NumPyClient` needed to be started via `start_numpy_client`. In our efforts to consolidate the core framework, we have introduced changes, and now all client types should start via `start_client`. To continue using `NumPyClient` clients, you simply need to first call the `.to_client()` method and then pass returned `Client` object to `start_client`. The examples and the documentation have been updated accordingly. - **Update Flower Baselines** From d1c675f0711d2b480e201125ee6c168d82fe4e2c Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Tue, 30 Jan 2024 11:13:43 +0100 Subject: [PATCH 13/16] Update doc/source/tutorial-quickstart-pytorch.rst --- doc/source/tutorial-quickstart-pytorch.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/tutorial-quickstart-pytorch.rst b/doc/source/tutorial-quickstart-pytorch.rst index c1068253f2d9..f15a4a93114e 100644 --- a/doc/source/tutorial-quickstart-pytorch.rst +++ b/doc/source/tutorial-quickstart-pytorch.rst @@ -191,7 +191,7 @@ to actually run this client: .. code-block:: python - fl.client.start_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()`. 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 From ad09b110f161c24e9211aea877128b341b6a4c17 Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Tue, 30 Jan 2024 11:16:02 +0100 Subject: [PATCH 14/16] Update src/py/flwr/client/app.py --- src/py/flwr/client/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 7e31b799089d..f1373388465c 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -402,7 +402,7 @@ def start_numpy_client( Warning ------- This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` - instead and first convert your client to type :code:`flwr.client.Client` by + instead and first convert your `NumPyClient` to type :code:`flwr.client.Client` by exectuing its :code:`to_client()` method. Parameters From 7a26bba75804aec8e02244ba074977ab5bce0a50 Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Tue, 30 Jan 2024 11:16:35 +0100 Subject: [PATCH 15/16] Update src/py/flwr/client/app.py --- src/py/flwr/client/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index f1373388465c..9c8640a84e87 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -402,7 +402,7 @@ def start_numpy_client( Warning ------- This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` - instead and first convert your `NumPyClient` to type :code:`flwr.client.Client` by + instead and first convert your :code:`NumPyClient` to type :code:`flwr.client.Client` by exectuing its :code:`to_client()` method. Parameters From fd1a2f63a0f61baad75440583f1de0cdef42a3d8 Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Tue, 30 Jan 2024 11:17:22 +0100 Subject: [PATCH 16/16] Update src/py/flwr/client/app.py --- src/py/flwr/client/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py index 9c8640a84e87..2f02e753d63a 100644 --- a/src/py/flwr/client/app.py +++ b/src/py/flwr/client/app.py @@ -402,8 +402,8 @@ def start_numpy_client( Warning ------- This function is deprecated since 1.7.0. Use :code:`flwr.client.start_client` - instead and first convert your :code:`NumPyClient` to type :code:`flwr.client.Client` by - exectuing its :code:`to_client()` method. + instead and first convert your :code:`NumPyClient` to type + :code:`flwr.client.Client` by executing its :code:`to_client()` method. Parameters ----------