From 5d0635a291609e268b75c10fc9eb61033f31b544 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Tue, 21 Apr 2026 03:54:00 +0000 Subject: [PATCH] feat: beta deploys all services with pipeline toggle defaulting to OFF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pipelineEnabled: true in beta so all pods run (Kargo happy) - PIPELINE_DEFAULT_OFF=true in beta config — scheduler initializes the Redis toggle to OFF on first boot - Shared Ollama (10.1.1.12:2701) between beta and paper - Flip pipeline ON from the UI when testing, OFF when done - Optimistic UI update for the toggle button --- frontend/src/api/hooks.ts | 8 +++++++- infra/helm/stonks-oracle/values-beta.yaml | 11 ++++++++--- services/scheduler/app.py | 9 +++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/frontend/src/api/hooks.ts b/frontend/src/api/hooks.ts index f1b9532..c529f79 100644 --- a/frontend/src/api/hooks.ts +++ b/frontend/src/api/hooks.ts @@ -537,7 +537,13 @@ export function usePipelineToggle() { const qc = useQueryClient(); return useMutation({ mutationFn: (enabled: boolean) => apiPost<{ pipeline_enabled: boolean }>('query', '/api/ops/pipeline/toggle', { enabled }), - onSuccess: () => qc.invalidateQueries({ queryKey: ['pipeline-health'] }), + onMutate: async (enabled) => { + await qc.cancelQueries({ queryKey: ['pipeline-health'] }); + qc.setQueriesData>({ queryKey: ['pipeline-health'] }, (old) => + old ? { ...old, pipeline_enabled: enabled } : old, + ); + }, + onSettled: () => qc.invalidateQueries({ queryKey: ['pipeline-health'] }), }); } diff --git a/infra/helm/stonks-oracle/values-beta.yaml b/infra/helm/stonks-oracle/values-beta.yaml index 4731a78..fae7dd5 100644 --- a/infra/helm/stonks-oracle/values-beta.yaml +++ b/infra/helm/stonks-oracle/values-beta.yaml @@ -6,10 +6,12 @@ image: tag: latest -## Pipeline OFF by default — beta is for API testing only -pipelineEnabled: false +## Pipeline ON — all services deployed so Kargo sees them as healthy. +## The Redis-based pipeline toggle defaults to OFF so the scheduler +## won't enqueue jobs unless you flip it on from the UI. +pipelineEnabled: true -## Single replica for API services +## Single replica for all services in beta services: queryApi: replicas: 1 @@ -34,6 +36,9 @@ config: MINIO_ENDPOINT: "minio.minio-service.svc.cluster.local:80" MINIO_SECURE: "false" BROKER_MODE: "paper" + OLLAMA_BASE_URL: "http://10.1.1.12:2701" + MARKET_DATA_BASE_URL: "https://api.polygon.io" + PIPELINE_DEFAULT_OFF: "true" ## Blank out all secrets so beta never talks to external APIs secrets: diff --git a/services/scheduler/app.py b/services/scheduler/app.py index b70c78c..faa3547 100644 --- a/services/scheduler/app.py +++ b/services/scheduler/app.py @@ -9,6 +9,7 @@ Requirements: 2.1, 2.2, 2.3, 2.4, 2.5 import asyncio import json import logging +import os from datetime import datetime, timezone from typing import Any, Optional @@ -501,6 +502,14 @@ async def main() -> None: logger.info("Scheduler started (tick=%ds)", SCHEDULER_TICK) pipeline_key = f"{PREFIX}:pipeline:enabled" + + # If PIPELINE_DEFAULT_OFF is set, initialize the toggle to OFF on first boot + # (only if the key doesn't already exist — preserves manual overrides) + if os.getenv("PIPELINE_DEFAULT_OFF", "").lower() in ("1", "true", "yes"): + created = await rds.set(pipeline_key, "0", nx=True) + if created: + logger.info("Pipeline toggle initialized to OFF (PIPELINE_DEFAULT_OFF=true)") + recovery_counter = 0 retry_counter = 0 cleanup_counter = 0