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

Updates Ray to 2.2.0 and fixes Mypy errors #1555

Merged
merged 8 commits into from
Jan 10, 2023
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protobuf = "^3.19.0"
importlib-metadata = { version = "^4.0.0", markers = "python_version < '3.8'" }
iterators = "^0.0.2"
# Optional dependencies
ray = { extras = ["default"], version = "~2.0.0", optional = true }
ray = { extras = ["default"], version = "~2.2.0", optional = true }

[tool.poetry.extras]
simulation = ["ray"]
Expand Down
8 changes: 4 additions & 4 deletions src/py/flwr/simulation/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,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:
ray.shutdown()
if ray.is_initialized() and not keep_initialised: # type: ignore
ray.shutdown() # type: ignore

# Initialize Ray
ray.init(**ray_init_args)
ray.init(**ray_init_args) # type: ignore
log(
INFO,
"Flower VCE: Ray initialized with resources: %s",
ray.cluster_resources(),
ray.cluster_resources(), # type: ignore
)

# Register one RayClientProxy object for each client with the ClientManager
Expand Down
24 changes: 12 additions & 12 deletions src/py/flwr/simulation/ray_transport/ray_client_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ 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( # type: ignore
future_get_properties_res = launch_and_get_properties.options(
**self.resources,
).remote(self.client_fn, self.cid, ins)
try:
res = ray.get(future_get_properties_res, timeout=timeout)
res = ray.get(future_get_properties_res, timeout=timeout) # type: ignore
except Exception as ex:
log(DEBUG, ex)
raise ex
Expand All @@ -63,11 +63,11 @@ 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( # type: ignore
future_paramseters_res = launch_and_get_parameters.options(
**self.resources,
).remote(self.client_fn, self.cid, ins)
try:
res = ray.get(future_paramseters_res, timeout=timeout)
res = ray.get(future_paramseters_res, timeout=timeout) # type: ignore
except Exception as ex:
log(DEBUG, ex)
raise ex
Expand All @@ -78,11 +78,11 @@ 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( # type: ignore
future_fit_res = launch_and_fit.options(
**self.resources,
).remote(self.client_fn, self.cid, ins)
try:
res = ray.get(future_fit_res, timeout=timeout)
res = ray.get(future_fit_res, timeout=timeout) # type: ignore
except Exception as ex:
log(DEBUG, ex)
raise ex
Expand All @@ -95,11 +95,11 @@ 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( # type: ignore
future_evaluate_res = launch_and_evaluate.options(
**self.resources,
).remote(self.client_fn, self.cid, ins)
try:
res = ray.get(future_evaluate_res, timeout=timeout)
res = ray.get(future_evaluate_res, timeout=timeout) # type: ignore
except Exception as ex:
log(DEBUG, ex)
raise ex
Expand All @@ -115,7 +115,7 @@ def reconnect(
return common.DisconnectRes(reason="") # Nothing to do here (yet)


@ray.remote
@ray.remote # type: ignore
def launch_and_get_properties(
client_fn: ClientFn, cid: str, get_properties_ins: common.GetPropertiesIns
) -> common.GetPropertiesRes:
Expand All @@ -127,7 +127,7 @@ def launch_and_get_properties(
)


@ray.remote
@ray.remote # type: ignore
def launch_and_get_parameters(
client_fn: ClientFn, cid: str, get_parameters_ins: common.GetParametersIns
) -> common.GetParametersRes:
Expand All @@ -139,7 +139,7 @@ def launch_and_get_parameters(
)


@ray.remote
@ray.remote # type: ignore
def launch_and_fit(
client_fn: ClientFn, cid: str, fit_ins: common.FitIns
) -> common.FitRes:
Expand All @@ -151,7 +151,7 @@ def launch_and_fit(
)


@ray.remote
@ray.remote # type: ignore
def launch_and_evaluate(
client_fn: ClientFn, cid: str, evaluate_ins: common.EvaluateIns
) -> common.EvaluateRes:
Expand Down