3fe48b37d4
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 209h38m38s
CI/CD Pipeline / Frontend Lint (push) Failing after 209h50m50s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 209h50m56s
80 lines
1.9 KiB
Python
80 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime, timezone
|
|
|
|
if sys.version_info >= (3, 11):
|
|
from enum import StrEnum
|
|
else:
|
|
from enum import Enum
|
|
|
|
class StrEnum(str, Enum):
|
|
pass
|
|
|
|
|
|
from typing import Any
|
|
from uuid import uuid4
|
|
|
|
|
|
class AssetLibraryKind(StrEnum):
|
|
VIDEO = "video"
|
|
VOICE = "voice"
|
|
|
|
|
|
class IngestJobStatus(StrEnum):
|
|
PENDING = "pending"
|
|
PROCESSING = "processing"
|
|
COMPLETED = "completed"
|
|
FAILED = "failed"
|
|
|
|
|
|
class ClassificationJobStatus(StrEnum):
|
|
PENDING = "pending"
|
|
PROCESSING = "processing"
|
|
COMPLETED = "completed"
|
|
FAILED = "failed"
|
|
|
|
|
|
class AssetClassification(StrEnum):
|
|
"""Asset classification categories."""
|
|
|
|
SCENIC = "scenic" # 风景
|
|
PRODUCT = "product" # 产品
|
|
PERSON = "person" # 人物
|
|
ANIMAL = "animal" # 动物
|
|
FOOD = "food" # 美食
|
|
TECH = "tech" # 科技
|
|
SPORT = "sport" # 运动
|
|
MUSIC = "music" # 音乐
|
|
OTHER = "other" # 其他
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ClassificationJob:
|
|
id: str
|
|
project_id: str
|
|
asset_id: str
|
|
status: ClassificationJobStatus = ClassificationJobStatus.PENDING
|
|
classification: str = "" # Result: AssetClassification value
|
|
confidence: float = 0.0 # 0.0 - 1.0
|
|
error_message: str = ""
|
|
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
|
|
@classmethod
|
|
def create(
|
|
cls,
|
|
project_id: str,
|
|
asset_id: str,
|
|
) -> "ClassificationJob":
|
|
if not project_id.strip():
|
|
raise ValueError("project_id 不能为空")
|
|
if not asset_id.strip():
|
|
raise ValueError("asset_id 不能为空")
|
|
return cls(
|
|
id=uuid4().hex,
|
|
project_id=project_id.strip(),
|
|
asset_id=asset_id.strip(),
|
|
)
|