Rework radar system
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Process supervisor for lifecycle management of C++ pipeline binaries."""
|
||||
"""Process supervisor for lifecycle management of pipeline subprocesses."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -133,13 +133,13 @@ class ProcessSupervisor:
|
||||
|
||||
def is_running(self) -> bool:
|
||||
"""Return whether acquisition-side processes are alive."""
|
||||
return self._is_alive("data_preprocessor") or self._is_alive("sweep_orchestrator")
|
||||
return self._is_alive("data_preprocessor") or self._is_alive("acquisition")
|
||||
|
||||
def is_processor_running(self) -> bool:
|
||||
"""Return whether data processor process is alive."""
|
||||
return self._is_alive("data_processor")
|
||||
|
||||
def start(self, config_path: Path, *, allow_clean_orchestrator_exit: bool = False) -> None:
|
||||
def start(self, config_path: Path, *, allow_clean_acquisition_exit: bool = False) -> None:
|
||||
"""Start required pipeline binaries and wait until they are ready."""
|
||||
if self.is_running():
|
||||
raise RuntimeError("Acquisition processes are already running")
|
||||
@@ -148,9 +148,9 @@ class ProcessSupervisor:
|
||||
self._kill_kamil_collectors()
|
||||
|
||||
logger.info(
|
||||
"Starting pipeline from config %s (allow_clean_orchestrator_exit=%s)",
|
||||
"Starting pipeline from config %s (allow_clean_acquisition_exit=%s)",
|
||||
config_path,
|
||||
allow_clean_orchestrator_exit,
|
||||
allow_clean_acquisition_exit,
|
||||
)
|
||||
acquisition_command = self._acquisition_command(config_path)
|
||||
command_specs = {
|
||||
@@ -164,12 +164,12 @@ class ProcessSupervisor:
|
||||
"--config",
|
||||
str(config_path),
|
||||
],
|
||||
"sweep_orchestrator": acquisition_command,
|
||||
"acquisition": acquisition_command,
|
||||
}
|
||||
processor_was_running = self.is_processor_running()
|
||||
required_processes: list[str] = ["data_preprocessor"]
|
||||
if not allow_clean_orchestrator_exit:
|
||||
required_processes.append("sweep_orchestrator")
|
||||
if not allow_clean_acquisition_exit:
|
||||
required_processes.append("acquisition")
|
||||
if not processor_was_running:
|
||||
required_processes.insert(0, "data_processor")
|
||||
|
||||
@@ -179,9 +179,9 @@ class ProcessSupervisor:
|
||||
|
||||
self._spawn("data_preprocessor", command_specs["data_preprocessor"], allow_clean_exit=False)
|
||||
self._spawn(
|
||||
"sweep_orchestrator",
|
||||
command_specs["sweep_orchestrator"],
|
||||
allow_clean_exit=allow_clean_orchestrator_exit,
|
||||
"acquisition",
|
||||
command_specs["acquisition"],
|
||||
allow_clean_exit=allow_clean_acquisition_exit,
|
||||
)
|
||||
self._wait_until_ready(required_processes)
|
||||
except Exception:
|
||||
@@ -196,12 +196,12 @@ class ProcessSupervisor:
|
||||
|
||||
def stop(self) -> None:
|
||||
"""Stop acquisition-side processes, keep processor process intact."""
|
||||
self._stop_processes(["sweep_orchestrator", "data_preprocessor"])
|
||||
self._stop_processes(["acquisition", "data_preprocessor"])
|
||||
self._kill_kamil_collectors()
|
||||
|
||||
def stop_orchestrator(self) -> None:
|
||||
"""Stop orchestrator process only."""
|
||||
self._stop_processes(["sweep_orchestrator"])
|
||||
def stop_acquisition(self) -> None:
|
||||
"""Stop acquisition process only."""
|
||||
self._stop_processes(["acquisition"])
|
||||
|
||||
def stop_preprocessor(self) -> None:
|
||||
"""Stop preprocessor process only."""
|
||||
@@ -209,7 +209,7 @@ class ProcessSupervisor:
|
||||
|
||||
def stop_all(self) -> None:
|
||||
"""Stop all managed processes."""
|
||||
self._stop_processes(["sweep_orchestrator", "data_preprocessor", "data_processor"])
|
||||
self._stop_processes(["acquisition", "data_preprocessor", "data_processor"])
|
||||
self._kill_kamil_collectors()
|
||||
|
||||
def _spawn(self, name: str, command: list[str], *, allow_clean_exit: bool) -> None:
|
||||
@@ -276,7 +276,7 @@ class ProcessSupervisor:
|
||||
|
||||
def _acquisition_command(self, config_path: Path) -> list[str]:
|
||||
"""Select the same acquisition producer as the shell launcher."""
|
||||
return acquisition_command(self._project_root, config_path)
|
||||
return acquisition_command(config_path)
|
||||
|
||||
def _stop_processes(self, names: Iterable[str]) -> None:
|
||||
"""Gracefully terminate processes, then force-kill on per-process timeout."""
|
||||
@@ -552,7 +552,7 @@ class ProcessSupervisor:
|
||||
Reads `/proc/<pid>/cmdline` so a recycled PID owned by an unrelated
|
||||
process is never killed.
|
||||
"""
|
||||
native_names = {"data_processor", "data_preprocessor", "sweep_orchestrator"}
|
||||
native_names = {"data_processor", "data_preprocessor"}
|
||||
producer_modules = {
|
||||
"python_app.scripts.matrix_raw_producer",
|
||||
"python_app.scripts.kamil_adc_raw_producer",
|
||||
|
||||
Reference in New Issue
Block a user