phase 3
This commit is contained in:
@@ -64,6 +64,22 @@ def list_profiles():
|
||||
return [{"name": name} for name in _PROFILES]
|
||||
|
||||
|
||||
@router.get("/config/profiles/{profile_name}/pipeline")
|
||||
def get_pipeline_config(profile_name: str):
|
||||
"""Return the pipeline composition for a profile."""
|
||||
from detect.profiles import get_profile
|
||||
from fastapi import HTTPException
|
||||
from dataclasses import asdict
|
||||
|
||||
try:
|
||||
profile = get_profile(profile_name)
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=404, detail=f"Unknown profile: {profile_name}")
|
||||
|
||||
config = profile.pipeline_config()
|
||||
return asdict(config)
|
||||
|
||||
|
||||
@router.get("/config/stages", response_model=list[StageConfigInfo])
|
||||
def list_stage_configs():
|
||||
"""Return the stage palette with config field metadata for the editor."""
|
||||
|
||||
@@ -88,7 +88,7 @@ def run_pipeline(req: RunRequest):
|
||||
log_level=req.log_level,
|
||||
)
|
||||
|
||||
pipeline = get_pipeline(checkpoint=req.checkpoint)
|
||||
pipeline = get_pipeline(checkpoint=req.checkpoint, profile_name=req.profile_name)
|
||||
|
||||
initial_state = DetectState(
|
||||
video_path=local_path,
|
||||
|
||||
@@ -35,6 +35,7 @@ from .detect import DETECT_VIEWS # noqa: F401 — discovered by modelgen generi
|
||||
from .inference import INFERENCE_VIEWS # noqa: F401 — GPU inference server API types
|
||||
from .ui_state import UI_STATE_VIEWS # noqa: F401 — UI store state types
|
||||
from .stages import StageConfigField, StageIO, StageDefinition, STAGE_VIEWS # noqa: F401
|
||||
from .pipeline_config import StageRef, Edge, PipelineConfig, PIPELINE_CONFIG_VIEWS # noqa: F401
|
||||
from .detect_api import RunRequest, RunResponse, DETECT_API_VIEWS # noqa: F401
|
||||
from .views import ChunkEvent, ChunkOutputFile, PipelineStats, WorkerEvent
|
||||
from .sources import ChunkInfo, SourceJob, SourceType
|
||||
|
||||
46
core/schema/models/pipeline_config.py
Normal file
46
core/schema/models/pipeline_config.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
Pipeline composition config — source of truth for graph topology.
|
||||
|
||||
Defines what stages run, in what order, with what branching.
|
||||
Belongs to a profile. Persisted as JSONB.
|
||||
|
||||
The execution strategy (serial, parallel, distributed) is separate —
|
||||
the runner reads this config and flattens it into a sequence for now.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class StageRef:
|
||||
"""Reference to a stage in the pipeline graph."""
|
||||
name: str # stage name (matches StageDefinition.name)
|
||||
branch: str = "trunk" # which branch this belongs to
|
||||
execution_target: str = "local" # local | gpu | lambda | gcp
|
||||
|
||||
|
||||
@dataclass
|
||||
class Edge:
|
||||
"""Connection between stages in the graph."""
|
||||
source: str # stage name
|
||||
target: str # stage name
|
||||
condition: str = "" # empty = unconditional, otherwise a routing rule key
|
||||
|
||||
|
||||
@dataclass
|
||||
class PipelineConfig:
|
||||
"""
|
||||
Pipeline graph topology + routing rules.
|
||||
|
||||
Holder model — stages/edges define the graph shape,
|
||||
routing_rules is a JSONB blob for decision tree logic.
|
||||
"""
|
||||
name: str
|
||||
profile_name: str
|
||||
stages: List[StageRef] = field(default_factory=list)
|
||||
edges: List[Edge] = field(default_factory=list)
|
||||
routing_rules: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
PIPELINE_CONFIG_VIEWS = [StageRef, Edge, PipelineConfig]
|
||||
Reference in New Issue
Block a user