From ab2923a0092dbaab16ccb4c122ca21db418af633 Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Wed, 1 Mar 2023 11:19:08 +0100 Subject: [PATCH 1/3] Update Ray to 2.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a2f08900d11..71dd2d4179a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ protobuf = "^3.19.0" importlib-metadata = { version = "^4.0.0", markers = "python_version < '3.8'" } iterators = "^0.0.2" # Optional dependencies (VCE) -ray = { extras = ["default"], version = "~2.2.0", optional = true } +ray = { extras = ["default"], version = "~2.3.0", optional = true } # Optional dependencies (REST transport layer) requests = "^2.28.2" fastapi = "^0.92.0" From 92d3409073edd85f720249c5b29f865f36d0bb77 Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Wed, 1 Mar 2023 11:40:29 +0100 Subject: [PATCH 2/3] Remove unused comments --- src/py/flwr/simulation/app.py | 8 ++++---- .../simulation/ray_transport/ray_client_proxy.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/py/flwr/simulation/app.py b/src/py/flwr/simulation/app.py index 2ff449a15c2..f285b373590 100644 --- a/src/py/flwr/simulation/app.py +++ b/src/py/flwr/simulation/app.py @@ -171,15 +171,15 @@ def start_simulation( # pylint: disable=too-many-arguments } # Shut down Ray if it has already been initialized (unless asked not to) - if ray.is_initialized() and not keep_initialised: # type: ignore - ray.shutdown() # type: ignore + if ray.is_initialized() and not keep_initialised: + ray.shutdown() # Initialize Ray - ray.init(**ray_init_args) # type: ignore + ray.init(**ray_init_args) log( INFO, "Flower VCE: Ray initialized with resources: %s", - ray.cluster_resources(), # type: ignore + ray.cluster_resources(), ) # Register one RayClientProxy object for each client with the ClientManager diff --git a/src/py/flwr/simulation/ray_transport/ray_client_proxy.py b/src/py/flwr/simulation/ray_transport/ray_client_proxy.py index aa31e4dff78..ddbc0687a46 100644 --- a/src/py/flwr/simulation/ray_transport/ray_client_proxy.py +++ b/src/py/flwr/simulation/ray_transport/ray_client_proxy.py @@ -50,7 +50,7 @@ def get_properties( **self.resources, ).remote(self.client_fn, self.cid, ins) try: - res = ray.get(future_get_properties_res, timeout=timeout) # type: ignore + res = ray.get(future_get_properties_res, timeout=timeout) except Exception as ex: log(DEBUG, ex) raise ex @@ -67,7 +67,7 @@ def get_parameters( **self.resources, ).remote(self.client_fn, self.cid, ins) try: - res = ray.get(future_paramseters_res, timeout=timeout) # type: ignore + res = ray.get(future_paramseters_res, timeout=timeout) except Exception as ex: log(DEBUG, ex) raise ex @@ -82,7 +82,7 @@ def fit(self, ins: common.FitIns, timeout: Optional[float]) -> common.FitRes: **self.resources, ).remote(self.client_fn, self.cid, ins) try: - res = ray.get(future_fit_res, timeout=timeout) # type: ignore + res = ray.get(future_fit_res, timeout=timeout) except Exception as ex: log(DEBUG, ex) raise ex @@ -99,7 +99,7 @@ def evaluate( **self.resources, ).remote(self.client_fn, self.cid, ins) try: - res = ray.get(future_evaluate_res, timeout=timeout) # type: ignore + res = ray.get(future_evaluate_res, timeout=timeout) except Exception as ex: log(DEBUG, ex) raise ex @@ -115,7 +115,7 @@ def reconnect( return common.DisconnectRes(reason="") # Nothing to do here (yet) -@ray.remote # type: ignore +@ray.remote def launch_and_get_properties( client_fn: ClientFn, cid: str, get_properties_ins: common.GetPropertiesIns ) -> common.GetPropertiesRes: @@ -127,7 +127,7 @@ def launch_and_get_properties( ) -@ray.remote # type: ignore +@ray.remote def launch_and_get_parameters( client_fn: ClientFn, cid: str, get_parameters_ins: common.GetParametersIns ) -> common.GetParametersRes: @@ -139,7 +139,7 @@ def launch_and_get_parameters( ) -@ray.remote # type: ignore +@ray.remote def launch_and_fit( client_fn: ClientFn, cid: str, fit_ins: common.FitIns ) -> common.FitRes: @@ -151,7 +151,7 @@ def launch_and_fit( ) -@ray.remote # type: ignore +@ray.remote def launch_and_evaluate( client_fn: ClientFn, cid: str, evaluate_ins: common.EvaluateIns ) -> common.EvaluateRes: From 6bc00500d543eeb9f73bf96a275a15ea49161c9e Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Wed, 1 Mar 2023 13:09:49 +0100 Subject: [PATCH 3/3] Ignore type for ray options --- src/py/flwr/simulation/ray_transport/ray_client_proxy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py/flwr/simulation/ray_transport/ray_client_proxy.py b/src/py/flwr/simulation/ray_transport/ray_client_proxy.py index ddbc0687a46..3a01e1ff5dc 100644 --- a/src/py/flwr/simulation/ray_transport/ray_client_proxy.py +++ b/src/py/flwr/simulation/ray_transport/ray_client_proxy.py @@ -46,7 +46,7 @@ def get_properties( self, ins: common.GetPropertiesIns, timeout: Optional[float] ) -> common.GetPropertiesRes: """Returns client's properties.""" - future_get_properties_res = launch_and_get_properties.options( + future_get_properties_res = launch_and_get_properties.options( # type: ignore **self.resources, ).remote(self.client_fn, self.cid, ins) try: @@ -63,7 +63,7 @@ def get_parameters( self, ins: common.GetParametersIns, timeout: Optional[float] ) -> common.GetParametersRes: """Return the current local model parameters.""" - future_paramseters_res = launch_and_get_parameters.options( + future_paramseters_res = launch_and_get_parameters.options( # type: ignore **self.resources, ).remote(self.client_fn, self.cid, ins) try: @@ -78,7 +78,7 @@ def get_parameters( def fit(self, ins: common.FitIns, timeout: Optional[float]) -> common.FitRes: """Train model parameters on the locally held dataset.""" - future_fit_res = launch_and_fit.options( + future_fit_res = launch_and_fit.options( # type: ignore **self.resources, ).remote(self.client_fn, self.cid, ins) try: @@ -95,7 +95,7 @@ def evaluate( self, ins: common.EvaluateIns, timeout: Optional[float] ) -> common.EvaluateRes: """Evaluate model parameters on the locally held dataset.""" - future_evaluate_res = launch_and_evaluate.options( + future_evaluate_res = launch_and_evaluate.options( # type: ignore **self.resources, ).remote(self.client_fn, self.cid, ins) try: