Skip to content

Commit 63f6816

Browse files
committed
Fix runner log path in WM by passing it from ER.
1 parent f189107 commit 63f6816

6 files changed

Lines changed: 37 additions & 4 deletions

File tree

docs/wm-er-protocol.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ The protocol is LSP-shaped with a small set of custom commands.
6464
- `handlers_to_initialize`: map of action name → handler names (optional)
6565
- Result: `{}` (empty object)
6666

67+
- `finecodeRunner/getInfo`
68+
- Arguments: none
69+
- Result: `{ "logFilePath": "/abs/path/to/runner.log" | null }`
70+
- Returns runtime information about the runner. Currently reports the path
71+
to the runner's log file, or `null` if logging to a file is not configured.
72+
6773
- `actions/run`
6874
- Arguments:
6975
1. `action_name` (string)

finecode_extension_runner/src/finecode_extension_runner/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def start(
6363
/ "runner"
6464
/ "runner.log")
6565

66-
logs.setup_logging(log_level="INFO" if trace is False else "TRACE", log_file_path=log_file_path)
67-
66+
global_state.log_file_path = logs.setup_logging(log_level="INFO" if trace is False else "TRACE", log_file_path=log_file_path)
67+
6868
if debug is True:
6969
logger.info(f"Started debugger on 127.0.0.1:{debug_port}")
7070

finecode_extension_runner/src/finecode_extension_runner/global_state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
project_dir_path: Path | None = None
1010
log_level: Literal["TRACE", "INFO"] = "INFO"
1111
env_name: str = ""
12+
log_file_path: Path | None = None

finecode_extension_runner/src/finecode_extension_runner/logs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def reset_log_level_for_group(group: str):
114114
del log_level_by_group[group]
115115

116116

117-
def setup_logging(log_level: str, log_file_path: Path) -> None:
117+
def setup_logging(log_level: str, log_file_path: Path) -> Path:
118118
logger.remove()
119119

120120
# disable logging raw messages
@@ -124,7 +124,7 @@ def setup_logging(log_level: str, log_file_path: Path) -> None:
124124

125125
# ~~extension runner communicates with workspace manager with tcp, we can print logs
126126
# to stdout as well~~. See README.md
127-
save_logs_to_file(
127+
actual_log_file_path = save_logs_to_file(
128128
file_path=log_file_path,
129129
log_level=log_level,
130130
stdout=True,
@@ -162,5 +162,7 @@ def emit(self, record: logging.LogRecord) -> None:
162162
"finecode_extension_runner.impls.inmemory_cache", LogLevel.WARNING
163163
)
164164

165+
return actual_log_file_path
166+
165167

166168
__all__ = ["save_logs_to_file", "set_log_level_for_group", "reset_log_level_for_group", "setup_logging"]

src/finecode/wm_server/runner/_internal_client_api.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ async def notify_initialized(client: jsonrpc_client.JsonRpcClient) -> None:
4141
)
4242

4343

44+
async def get_runner_info(client: jsonrpc_client.JsonRpcClient) -> dict:
45+
logger.debug(f"Get runner info from {client.readable_id}")
46+
response = await client.send_request(
47+
method=_internal_client_types.WORKSPACE_EXECUTE_COMMAND,
48+
params=_internal_client_types.ExecuteCommandParams(
49+
command="finecodeRunner/getInfo",
50+
arguments=[],
51+
),
52+
timeout=10,
53+
)
54+
return response.result
55+
56+
4457
async def cancel_request(
4558
client: jsonrpc_client.JsonRpcClient, request_id: int | str
4659
) -> None:

src/finecode/wm_server/runner/runner_manager.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,17 @@ async def start_runner(
415415
runner.initialized_event.set()
416416
raise exception
417417

418+
try:
419+
runner_info = await _internal_client_api.get_runner_info(runner.client)
420+
log_file_path_str = runner_info.get("logFilePath")
421+
if log_file_path_str is not None:
422+
runner.log_file_path = Path(log_file_path_str)
423+
logger.debug(f"Runner {runner.readable_id} log file: {runner.log_file_path}")
424+
else:
425+
logger.debug(f"Runner {runner.readable_id} returned no log file path")
426+
except Exception as e:
427+
logger.warning(f"Failed to get runner info for {runner.readable_id}: {e}")
428+
418429
if (
419430
project_def.dir_path not in ws_context.ws_projects_raw_configs
420431
or not isinstance(project_def, domain.CollectedProject)

0 commit comments

Comments
 (0)