Skip to content

Commit

Permalink
Merge branch 'main' into fds-rename-node-id-to-partition-id
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Mar 13, 2024
2 parents a119cbd + 0abd7e4 commit 9f63c5d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 16 deletions.
24 changes: 22 additions & 2 deletions src/py/flwr/cli/new/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def new(
] = None,
) -> None:
"""Create new Flower project."""
print(f"Creating Flower project {project_name}...")
print(
typer.style(
f"🔨 Creating Flower project {project_name}...",
fg=typer.colors.GREEN,
bold=True,
)
)

if project_name is None:
project_name = prompt_text("Please provide project name")
Expand Down Expand Up @@ -131,4 +137,18 @@ def new(
context=context,
)

print("Project creation successful.")
print(
typer.style(
"🎊 Project creation successful.\n\n"
"Use the following command to run your project:\n",
fg=typer.colors.GREEN,
bold=True,
)
)
print(
typer.style(
f" cd {project_name}\n" + " pip install .\n flwr run\n",
fg=typer.colors.BRIGHT_CYAN,
bold=True,
)
)
5 changes: 1 addition & 4 deletions src/py/flwr/server/compat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
config=initialized_config,
)

# Terminate the thread
f_stop.set()

# Stop the Driver API server and the thread
del driver

thread.join()

event(EventType.START_SERVER_LEAVE)
Expand Down
4 changes: 2 additions & 2 deletions src/py/flwr/server/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def send_and_receive(
time.sleep(3)
return ret

def __del__(self) -> None:
"""Disconnect GrpcDriver if connected."""
def close(self) -> None:
"""Disconnect from the SuperLink if connected."""
# Check if GrpcDriver is initialized
if self.grpc_driver is None:
return
Expand Down
6 changes: 2 additions & 4 deletions src/py/flwr/server/driver/driver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,15 @@ def test_del_with_initialized_driver(self) -> None:
self.driver._get_grpc_driver_and_run_id()

# Execute
# pylint: disable-next=unnecessary-dunder-call
self.driver.__del__()
self.driver.close()

# Assert
self.mock_grpc_driver.disconnect.assert_called_once()

def test_del_with_uninitialized_driver(self) -> None:
"""Test cleanup behavior when Driver is not initialized."""
# Execute
# pylint: disable-next=unnecessary-dunder-call
self.driver.__del__()
self.driver.close()

# Assert
self.mock_grpc_driver.disconnect.assert_not_called()
2 changes: 1 addition & 1 deletion src/py/flwr/server/run_serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def run_server_app() -> None:
run(driver=driver, server_app_dir=server_app_dir, server_app_attr=server_app_attr)

# Clean up
driver.__del__() # pylint: disable=unnecessary-dunder-call
driver.close()

event(EventType.RUN_SERVER_APP_LEAVE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_node(
def delete_node(request: DeleteNodeRequest, state: State) -> DeleteNodeResponse:
"""."""
# Validate node_id
if request.node.anonymous or request.node.node_id <= 0:
if request.node.anonymous or request.node.node_id == 0:
return DeleteNodeResponse()

# Update state
Expand Down
1 change: 0 additions & 1 deletion src/py/flwr/server/workflow/default_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def __call__(self, driver: Driver, context: Context) -> None:

# Terminate the thread
f_stop.set()
del driver
thread.join()


Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/simulation/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _main_loop(
finally:
# Stop Driver
driver_server.stop(grace=0)
del driver
driver.close()
# Trigger stop event
f_stop.set()

Expand Down

0 comments on commit 9f63c5d

Please sign in to comment.