Skip to content

Commit 743d53c

Browse files
committed
feat: Add logger to AgentLauncher for better debugging and monitoring
1 parent e3f3cd4 commit 743d53c

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

adf_core_python/core/launcher/agent_launcher.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import importlib
22
import threading
3+
from logging import Logger, getLogger
34

45
from rcrs_core.connection.componentLauncher import ComponentLauncher
56

@@ -30,15 +31,18 @@
3031
class AgentLauncher:
3132
def __init__(self, config: Config):
3233
self.config = config
34+
self.logger: Logger = getLogger(__name__)
3335
self.connectors: list[Connector] = []
36+
self.thread_list: list[threading.Thread] = []
3437

3538
def initConnector(self):
3639
loader_name, loader_class_name = self.config.get_value(
37-
ConfigKey.KEY_LOADER_CLASS
38-
).split(".")
39-
self.loader: AbstractLoader = importlib.import_module(
40-
loader_name,
41-
).__getattr__(
40+
ConfigKey.KEY_LOADER_CLASS,
41+
"adf_core_python.implement.default_loader.DefaultLoader",
42+
).rsplit(".", 1)
43+
loader_module = importlib.import_module(loader_name)
44+
self.loader: AbstractLoader = getattr(
45+
loader_module,
4246
loader_class_name,
4347
)(
4448
self.config.get_value(ConfigKey.KEY_TEAM_NAME),
@@ -54,18 +58,23 @@ def initConnector(self):
5458
def launch(self):
5559
host: str = self.config.get_value(ConfigKey.KEY_KERNEL_HOST, "localhost")
5660
port: int = self.config.get_value(ConfigKey.KEY_KERNEL_PORT, 27931)
61+
self.logger.info(f"Start agent launcher (host: {host}, port: {port})")
62+
5763
component_launcher: ComponentLauncher = ComponentLauncher(port, host)
5864

59-
thread_list: list[threading.Thread] = []
6065
for connector in self.connectors:
6166
thread = threading.Thread(
6267
target=connector.connect,
6368
args=(component_launcher, self.config, self.loader),
6469
)
6570
thread.start()
66-
thread_list.append(thread)
71+
self.thread_list.append(thread)
6772

68-
for thread in thread_list:
73+
for thread in self.thread_list:
6974
thread.join()
7075

7176
connected_agent_count = 0
77+
for connector in self.connectors:
78+
connected_agent_count += connector.get_connected_agent_count()
79+
80+
self.logger.info(f"Connected agent count: {connected_agent_count}")

config/launcher.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ team:
88
adf:
99
launcher:
1010
precompute: 0
11-
adf:
12-
debug:
13-
flag: 0
14-
agent:
15-
moduleconfig:
16-
filename: config/module.yaml
11+
debug:
12+
flag: 0
13+
agent:
14+
moduleconfig:
15+
filename: config/module.yaml
1716

1817
develop:
1918
flag: 1

0 commit comments

Comments
 (0)