Skip to content

Commit

Permalink
Merge branch 'main' into update-hf-template
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljanes authored Sep 11, 2024
2 parents a1d0c25 + c85417a commit 3adce49
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/py/flwr/simulation/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def run_simulation_from_cli() -> None:
app_dir=app_dir,
run=run,
enable_tf_gpu_growth=args.enable_tf_gpu_growth,
delay_start=args.delay_start,
verbose_logging=args.verbose,
server_app_run_config=fused_config,
is_app=is_app,
Expand Down Expand Up @@ -309,7 +310,6 @@ def run_serverapp_th(
f_stop: threading.Event,
has_exception: threading.Event,
enable_tf_gpu_growth: bool,
delay_launch: int = 3,
) -> threading.Thread:
"""Run SeverApp in a thread."""

Expand Down Expand Up @@ -365,7 +365,6 @@ def server_th_with_start_checks(
server_app,
),
)
sleep(delay_launch)
serverapp_th.start()
return serverapp_th

Expand All @@ -380,6 +379,7 @@ def _main_loop(
enable_tf_gpu_growth: bool,
run: Run,
exit_event: EventType,
delay_start: int,
flwr_dir: Optional[str] = None,
client_app: Optional[ClientApp] = None,
client_app_attr: Optional[str] = None,
Expand Down Expand Up @@ -419,6 +419,9 @@ def _main_loop(
enable_tf_gpu_growth=enable_tf_gpu_growth,
)

# Buffer time so the `ServerApp` in separate thread is ready
log(DEBUG, "Buffer time delay: %ds", delay_start)
sleep(delay_start)
# Start Simulation Engine
vce.start_vce(
num_supernodes=num_supernodes,
Expand Down Expand Up @@ -467,6 +470,7 @@ def _run_simulation(
flwr_dir: Optional[str] = None,
run: Optional[Run] = None,
enable_tf_gpu_growth: bool = False,
delay_start: int = 5,
verbose_logging: bool = False,
is_app: bool = False,
) -> None:
Expand Down Expand Up @@ -523,6 +527,7 @@ def _run_simulation(
enable_tf_gpu_growth,
run,
exit_event,
delay_start,
flwr_dir,
client_app,
client_app_attr,
Expand Down Expand Up @@ -610,6 +615,13 @@ def _parse_args_run_simulation() -> argparse.ArgumentParser:
"Read more about how `tf.config.experimental.set_memory_growth()` works in "
"the TensorFlow documentation: https://www.tensorflow.org/api/stable.",
)
parser.add_argument(
"--delay-start",
type=int,
default=3,
help="Buffer time (in seconds) to delay the start the simulation engine after "
"the `ServerApp`, which runs in a separate thread, has been launched.",
)
parser.add_argument(
"--verbose",
action="store_true",
Expand Down

0 comments on commit 3adce49

Please sign in to comment.