Skip to content

Commit

Permalink
Merge branch 'main' into change-override-config-type
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll authored Jul 16, 2024
2 parents de789b0 + 1f3fe0f commit 2948d04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/py/flwr/client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _start_client_internal(
] = None,
max_retries: Optional[int] = None,
max_wait_time: Optional[float] = None,
flwr_dir: Optional[Path] = None,
flwr_path: Optional[Path] = None,
) -> None:
"""Start a Flower client node which connects to a Flower server.
Expand Down Expand Up @@ -241,7 +241,7 @@ class `flwr.client.Client` (default: None)
The maximum duration before the client stops trying to
connect to the server in case of connection error.
If set to None, there is no limit to the total time.
flwr_dir: Optional[Path] (default: None)
flwr_path: Optional[Path] (default: None)
The fully resolved path containing installed Flower Apps.
"""
if insecure is None:
Expand Down Expand Up @@ -402,7 +402,7 @@ def _on_backoff(retry_state: RetryState) -> None:

# Register context for this run
node_state.register_context(
run_id=run_id, run=runs[run_id], flwr_dir=flwr_dir
run_id=run_id, run=runs[run_id], flwr_path=flwr_path
)

# Retrieve context for this run
Expand Down
20 changes: 17 additions & 3 deletions src/py/flwr/client/node_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Dict, Optional

from flwr.common import Context, RecordSet
from flwr.common.config import get_fused_config
from flwr.common.config import get_fused_config, get_fused_config_from_dir
from flwr.common.typing import Run, UserConfig


Expand Down Expand Up @@ -48,11 +48,25 @@ def register_context(
self,
run_id: int,
run: Optional[Run] = None,
flwr_dir: Optional[Path] = None,
flwr_path: Optional[Path] = None,
app_dir: Optional[str] = None,
) -> None:
"""Register new run context for this node."""
if run_id not in self.run_infos:
initial_run_config = get_fused_config(run, flwr_dir) if run else {}
initial_run_config = {}
if app_dir:
# Load from app directory
app_path = Path(app_dir)
if app_path.is_dir():
override_config = run.override_config if run else {}
initial_run_config = get_fused_config_from_dir(
app_path, override_config
)
else:
raise ValueError("The specified `app_dir` must be a directory.")
else:
# Load from .fab
initial_run_config = get_fused_config(run, flwr_path) if run else {}
self.run_infos[run_id] = RunInfo(
initial_run_config=initial_run_config,
context=Context(
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/supernode/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run_supernode() -> None:
max_retries=args.max_retries,
max_wait_time=args.max_wait_time,
node_config=parse_config_args(args.node_config),
flwr_dir=get_flwr_dir(args.flwr_dir),
flwr_path=get_flwr_dir(args.flwr_dir),
)

# Graceful shutdown
Expand Down

0 comments on commit 2948d04

Please sign in to comment.