@@ -120,18 +120,30 @@ def _get_runtime_snapshot(kind: str) -> dict[str, Any]:
120120 is_running = bool (process and process .poll () is None )
121121 with _runtime_lock :
122122 state = _runtime_state [kind ]
123+ phase = state ["phase" ]
124+ exit_code = state ["exitCode" ]
125+ ended_at = state ["endedAt" ]
126+
127+ # Reconcile: if the process has exited but the log-reader thread
128+ # hasn't updated the state yet, derive phase from the process itself.
129+ if not is_running and phase == "running" and process is not None :
130+ rc = process .returncode
131+ phase = "finished" if rc == 0 else "failed"
132+ exit_code = rc
133+ ended_at = state ["endedAt" ] or _utc_now ()
134+
123135 lines = list (state ["lines" ])
124136 snapshot = {
125137 "isRunning" : is_running ,
126- "phase" : state [ " phase" ] ,
138+ "phase" : phase ,
127139 "pid" : process .pid if is_running else state ["pid" ],
128- "exitCode" : state [ "exitCode" ] ,
140+ "exitCode" : exit_code ,
129141 "command" : state ["command" ],
130142 "cwd" : state ["cwd" ],
131143 "configPath" : state ["configPath" ],
132144 "configOriginPath" : state ["configOriginPath" ],
133145 "startedAt" : state ["startedAt" ],
134- "endedAt" : state [ "endedAt" ] ,
146+ "endedAt" : ended_at ,
135147 "lastUpdatedAt" : state ["lastUpdatedAt" ],
136148 "lineCount" : state ["lineCount" ],
137149 "lastError" : state ["lastError" ],
@@ -367,10 +379,8 @@ def start_training(payload: dict):
367379 command = [
368380 sys .executable ,
369381 str (script_path ),
370- "--config" ,
382+ "--config-file " ,
371383 temp_filepath ,
372- "--mode" ,
373- "train" ,
374384 ]
375385 command .extend (
376386 _build_cli_arguments (
@@ -573,10 +583,9 @@ def start_inference(payload: dict):
573583 command = [
574584 sys .executable ,
575585 str (script_path ),
576- "--config" ,
586+ "--config-file " ,
577587 temp_filepath ,
578- "--mode" ,
579- "test" ,
588+ "--inference" ,
580589 ]
581590 command .extend (
582591 _build_cli_arguments (
0 commit comments