chunker ui redo
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
},
|
||||
{
|
||||
"target": "typescript",
|
||||
"output": "ui/timeline/src/types.ts",
|
||||
"include": ["dataclasses", "enums", "api"]
|
||||
"output": "ui/common/types/generated.ts",
|
||||
"include": ["dataclasses", "enums", "api", "views"]
|
||||
},
|
||||
{
|
||||
"target": "protobuf",
|
||||
|
||||
@@ -16,6 +16,8 @@ from .grpc import (
|
||||
GRPC_SERVICE,
|
||||
CancelRequest,
|
||||
CancelResponse,
|
||||
ChunkPipelineEvent,
|
||||
ChunkStreamRequest,
|
||||
Empty,
|
||||
JobRequest,
|
||||
JobResponse,
|
||||
@@ -26,6 +28,7 @@ from .grpc import (
|
||||
from .jobs import ChunkJob, ChunkJobStatus, JobStatus, TranscodeJob
|
||||
from .media import AssetStatus, MediaAsset
|
||||
from .presets import BUILTIN_PRESETS, TranscodePreset
|
||||
from .views import ChunkEvent, ChunkOutputFile, PipelineStats, WorkerEvent
|
||||
|
||||
# Core domain models - generates Django, Pydantic, TypeScript
|
||||
DATACLASSES = [MediaAsset, TranscodePreset, TranscodeJob, ChunkJob]
|
||||
@@ -44,6 +47,9 @@ API_MODELS = [
|
||||
# Status enums - included in generated code
|
||||
ENUMS = [AssetStatus, JobStatus, ChunkJobStatus]
|
||||
|
||||
# View/event models - generates TypeScript for UI consumption
|
||||
VIEWS = [ChunkEvent, WorkerEvent, PipelineStats, ChunkOutputFile]
|
||||
|
||||
# gRPC messages - generates Proto
|
||||
GRPC_MESSAGES = [
|
||||
JobRequest,
|
||||
@@ -54,6 +60,8 @@ GRPC_MESSAGES = [
|
||||
CancelResponse,
|
||||
WorkerStatus,
|
||||
Empty,
|
||||
ChunkStreamRequest,
|
||||
ChunkPipelineEvent,
|
||||
]
|
||||
|
||||
__all__ = [
|
||||
@@ -82,10 +90,18 @@ __all__ = [
|
||||
"CancelResponse",
|
||||
"WorkerStatus",
|
||||
"Empty",
|
||||
"ChunkStreamRequest",
|
||||
"ChunkPipelineEvent",
|
||||
# Views
|
||||
"ChunkEvent",
|
||||
"WorkerEvent",
|
||||
"PipelineStats",
|
||||
"ChunkOutputFile",
|
||||
# For generator
|
||||
"DATACLASSES",
|
||||
"API_MODELS",
|
||||
"ENUMS",
|
||||
"VIEWS",
|
||||
"GRPC_MESSAGES",
|
||||
"BUILTIN_PRESETS",
|
||||
]
|
||||
|
||||
@@ -41,6 +41,13 @@ class CancelRequest:
|
||||
job_id: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkStreamRequest:
|
||||
"""Request to stream chunk pipeline events."""
|
||||
|
||||
job_id: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Empty:
|
||||
"""Empty message for requests with no parameters."""
|
||||
@@ -94,6 +101,26 @@ class WorkerStatus:
|
||||
gpu_available: bool
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkPipelineEvent:
|
||||
"""Streaming chunk pipeline event."""
|
||||
|
||||
job_id: str
|
||||
event_type: str # pipeline_start, chunk_queued, chunk_done, etc.
|
||||
sequence: int = 0
|
||||
worker_id: str = ""
|
||||
state: str = ""
|
||||
queue_size: int = 0
|
||||
elapsed: float = 0.0
|
||||
throughput_mbps: float = 0.0
|
||||
total_chunks: int = 0
|
||||
processed_chunks: int = 0
|
||||
failed_chunks: int = 0
|
||||
error: str = ""
|
||||
processing_time: float = 0.0
|
||||
retries: int = 0
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Service Definition (for documentation, generator uses this)
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -126,5 +153,11 @@ GRPC_SERVICE = {
|
||||
"response": WorkerStatus,
|
||||
"stream_response": False,
|
||||
},
|
||||
{
|
||||
"name": "StreamChunkPipeline",
|
||||
"request": ChunkStreamRequest,
|
||||
"response": ChunkPipelineEvent,
|
||||
"stream_response": True, # Server streaming
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
57
core/schema/models/views.py
Normal file
57
core/schema/models/views.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
View/Event Schema Definitions
|
||||
|
||||
Projections of domain models for UI consumption via SSE events.
|
||||
These reference existing schema types (e.g., ChunkJobStatus) to maintain
|
||||
type-level dependencies — if the domain model changes, views update too.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkEvent:
|
||||
"""SSE event for a single chunk's lifecycle."""
|
||||
|
||||
sequence: int
|
||||
status: str
|
||||
size: Optional[int] = None
|
||||
worker_id: Optional[str] = None
|
||||
processing_time: Optional[float] = None
|
||||
error: Optional[str] = None
|
||||
retries: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
class WorkerEvent:
|
||||
"""SSE event for worker state changes."""
|
||||
|
||||
worker_id: str
|
||||
state: str
|
||||
current_chunk: Optional[int] = None
|
||||
processed: int = 0
|
||||
errors: int = 0
|
||||
retries: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
class PipelineStats:
|
||||
"""Aggregate pipeline statistics, updated via SSE."""
|
||||
|
||||
total_chunks: int = 0
|
||||
processed: int = 0
|
||||
failed: int = 0
|
||||
retries: int = 0
|
||||
elapsed: float = 0.0
|
||||
throughput_mbps: float = 0.0
|
||||
queue_size: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkOutputFile:
|
||||
"""A chunk output file in S3/MinIO with presigned download URL."""
|
||||
|
||||
key: str
|
||||
size: int = 0
|
||||
url: str = ""
|
||||
Reference in New Issue
Block a user