chore: remove legacy startup paths
This commit is contained in:
@@ -29,6 +29,17 @@ router = APIRouter(prefix="/api/runtime", tags=["runtime"])
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def _normalize_schedule_mode(value: Any) -> str:
|
||||
"""Normalize schedule mode to the current public vocabulary.
|
||||
|
||||
`intraday` is kept as a backward-compatible alias for `interval`.
|
||||
"""
|
||||
mode = str(value or "daily").strip().lower()
|
||||
if mode == "intraday":
|
||||
return "interval"
|
||||
return mode or "daily"
|
||||
|
||||
|
||||
class RuntimeState:
|
||||
"""Thread-safe singleton for managing runtime state.
|
||||
|
||||
@@ -439,6 +450,11 @@ def _is_gateway_running() -> bool:
|
||||
|
||||
Checks both the internally-managed gateway process and falls back to
|
||||
port availability (for externally-managed gateway processes).
|
||||
|
||||
The fallback matters because this codebase may still encounter two startup
|
||||
shapes while historical artifacts remain in-tree:
|
||||
1. runtime_service-managed Gateway subprocesses
|
||||
2. externally started historical Gateway processes outside the supported dev flow
|
||||
"""
|
||||
process = _runtime_state.gateway_process
|
||||
if process is not None and process.poll() is None:
|
||||
@@ -481,7 +497,11 @@ def _start_gateway_process(
|
||||
bootstrap: Dict[str, Any],
|
||||
port: int
|
||||
) -> subprocess.Popen:
|
||||
"""Start Gateway as a separate process."""
|
||||
"""Start Gateway as a runtime_service-managed subprocess.
|
||||
|
||||
This path is used when runtime lifecycle is driven through the runtime API.
|
||||
It is not the only supported way a Gateway may exist in the current repo.
|
||||
"""
|
||||
# Validate configuration before starting
|
||||
validation_errors = _validate_gateway_config(bootstrap)
|
||||
if validation_errors:
|
||||
@@ -592,9 +612,9 @@ def _validate_gateway_config(bootstrap: Dict[str, Any]) -> List[str]:
|
||||
errors.append("Dates must be in YYYY-MM-DD format")
|
||||
|
||||
# Validate schedule mode
|
||||
schedule_mode = bootstrap.get("schedule_mode", "daily")
|
||||
if schedule_mode not in ("daily", "intraday"):
|
||||
errors.append(f"Invalid schedule_mode '{schedule_mode}': must be 'daily' or 'intraday'")
|
||||
schedule_mode = _normalize_schedule_mode(bootstrap.get("schedule_mode", "daily"))
|
||||
if schedule_mode not in ("daily", "interval"):
|
||||
errors.append(f"Invalid schedule_mode '{schedule_mode}': must be 'daily' or 'interval'")
|
||||
|
||||
return errors
|
||||
|
||||
@@ -778,7 +798,7 @@ async def get_runtime_mode() -> RuntimeModeResponse:
|
||||
mode=mode,
|
||||
is_backtest=mode == "backtest",
|
||||
run_id=context.get("config_name"),
|
||||
schedule_mode=bootstrap.get("schedule_mode"),
|
||||
schedule_mode=_normalize_schedule_mode(bootstrap.get("schedule_mode")),
|
||||
is_running=True,
|
||||
)
|
||||
except HTTPException:
|
||||
@@ -909,7 +929,7 @@ def _resolve_runtime_response(run_id: str) -> RuntimeConfigResponse:
|
||||
project_root=PROJECT_ROOT,
|
||||
config_name=run_id,
|
||||
enable_memory=bool(bootstrap.get("enable_memory", False)),
|
||||
schedule_mode=str(bootstrap.get("schedule_mode", "daily")),
|
||||
schedule_mode=_normalize_schedule_mode(bootstrap.get("schedule_mode", "daily")),
|
||||
interval_minutes=int(bootstrap.get("interval_minutes", 60) or 60),
|
||||
trigger_time=str(bootstrap.get("trigger_time", "09:30") or "09:30"),
|
||||
)
|
||||
@@ -929,11 +949,11 @@ def _normalize_runtime_config_updates(
|
||||
updates: Dict[str, Any] = {}
|
||||
|
||||
if request.schedule_mode is not None:
|
||||
schedule_mode = str(request.schedule_mode).strip().lower()
|
||||
if schedule_mode not in {"daily", "intraday"}:
|
||||
schedule_mode = _normalize_schedule_mode(request.schedule_mode)
|
||||
if schedule_mode not in {"daily", "interval"}:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="schedule_mode must be 'daily' or 'intraday'",
|
||||
detail="schedule_mode must be 'daily' or 'interval'",
|
||||
)
|
||||
updates["schedule_mode"] = schedule_mode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user