Skip to content

Commit

Permalink
feat(framework:skip) Add verbose logging for SimulationEngine (#3913)
Browse files Browse the repository at this point in the history
  • Loading branch information
chongshenng authored Jul 26, 2024
1 parent 1f25189 commit 11702ca
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/py/flwr/superexec/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class SimulationEngine(Executor):
def __init__(
self,
num_supernodes: Optional[int] = None,
verbose: Optional[bool] = False,
) -> None:
self.num_supernodes = num_supernodes
self.verbose = verbose

@override
def set_config(
Expand All @@ -80,6 +82,8 @@ def set_config(
Supported configuration key/value pairs:
- "num-supernodes": int
Number of nodes to register for the simulation.
- "verbose": bool
Set verbosity of logs.
"""
if num_supernodes := config.get("num-supernodes"):
if not isinstance(num_supernodes, int):
Expand All @@ -97,6 +101,13 @@ def set_config(
"positive integer."
)

if verbose := config.get("verbose"):
if not isinstance(verbose, bool):
raise ValueError(
"The `verbose` value must be a string `true` or `false`."
)
self.verbose = verbose

@override
def start_run(
self,
Expand All @@ -121,10 +132,11 @@ def start_run(
fab_path = install_from_fab(fab_file, None, True)

# Install FAB Python package
subprocess.check_call(
subprocess.run(
[sys.executable, "-m", "pip", "install", "--no-deps", str(fab_path)],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdout=None if self.verbose else subprocess.DEVNULL,
stderr=None if self.verbose else subprocess.DEVNULL,
check=True,
)

# Load and validate config
Expand Down

0 comments on commit 11702ca

Please sign in to comment.