From 6056ac108522b7436ab439f84f739349b9a90970 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Thu, 28 Mar 2024 17:30:08 +0100 Subject: [PATCH] mirror app dir func in non-simulated settings --- src/py/flwr/server/superlink/fleet/vce/vce_api.py | 13 ++++++------- .../flwr/server/superlink/fleet/vce/vce_api_test.py | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/py/flwr/server/superlink/fleet/vce/vce_api.py b/src/py/flwr/server/superlink/fleet/vce/vce_api.py index 9e4bbb611a84..5bbcc6def393 100644 --- a/src/py/flwr/server/superlink/fleet/vce/vce_api.py +++ b/src/py/flwr/server/superlink/fleet/vce/vce_api.py @@ -14,9 +14,9 @@ # ============================================================================== """Fleet Simulation Engine API.""" - import asyncio import json +import sys import time import traceback from logging import DEBUG, ERROR, INFO, WARN @@ -89,11 +89,6 @@ async def worker( log(DEBUG, "Terminating Async worker: %s", e) break - except LoadClientAppError as load_ex: - log(ERROR, load_ex) - log(ERROR, traceback.format_exc()) - raise load_ex - # Exceptions aren't raised but reported as an error message except Exception as ex: # pylint: disable=broad-exception-caught log(ERROR, ex) @@ -227,7 +222,7 @@ async def run( await backend.terminate() -# pylint: disable=too-many-arguments,unused-argument,too-many-locals +# pylint: disable=too-many-arguments,unused-argument,too-many-locals,too-many-branches def start_vce( backend_name: str, backend_config_json_stream: str, @@ -313,6 +308,10 @@ def backend_fn() -> Backend: def _load() -> ClientApp: if client_app_attr: + + if app_dir is not None: + sys.path.insert(0, app_dir) + app: ClientApp = load_app(client_app_attr, LoadClientAppError) if not isinstance(app, ClientApp): diff --git a/src/py/flwr/server/superlink/fleet/vce/vce_api_test.py b/src/py/flwr/server/superlink/fleet/vce/vce_api_test.py index 5eded758da6f..66c3c21326d5 100644 --- a/src/py/flwr/server/superlink/fleet/vce/vce_api_test.py +++ b/src/py/flwr/server/superlink/fleet/vce/vce_api_test.py @@ -27,6 +27,7 @@ from unittest import IsolatedAsyncioTestCase from uuid import UUID +from flwr.client.client_app import LoadClientAppError from flwr.common import ( DEFAULT_TTL, GetPropertiesIns, @@ -193,7 +194,7 @@ def test_erroneous_client_app_attr(self) -> None: state_factory, nodes_mapping, _ = init_state_factory_nodes_mapping( num_nodes=num_nodes, num_messages=num_messages ) - with self.assertRaises(RuntimeError): + with self.assertRaises(LoadClientAppError): start_and_shutdown( client_app_attr="totally_fictitious_app:client", state_factory=state_factory,