| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- """
- Pydantic schemas for Project API.
- Defines request and response models for project operations.
- """
- from datetime import datetime
- from typing import Optional
- from pydantic import BaseModel, Field
- class ProjectCreate(BaseModel):
- """Schema for creating a new project."""
-
- name: str = Field(..., min_length=1, description="Project name")
- description: str = Field(default="", description="Project description")
- config: str = Field(..., min_length=1, description="Label Studio configuration")
-
- class Config:
- json_schema_extra = {
- "example": {
- "name": "Image Classification Project",
- "description": "Classify images into categories",
- "config": "<View><Image name='image' value='$image'/><Choices name='choice' toName='image'><Choice value='Cat'/><Choice value='Dog'/></Choices></View>"
- }
- }
- class ProjectUpdate(BaseModel):
- """Schema for updating an existing project."""
-
- name: Optional[str] = Field(None, min_length=1, description="Project name")
- description: Optional[str] = Field(None, description="Project description")
- config: Optional[str] = Field(None, min_length=1, description="Label Studio configuration")
-
- class Config:
- json_schema_extra = {
- "example": {
- "name": "Updated Project Name",
- "description": "Updated description"
- }
- }
- class ProjectResponse(BaseModel):
- """Schema for project response."""
-
- id: str = Field(..., description="Project unique identifier")
- name: str = Field(..., description="Project name")
- description: str = Field(..., description="Project description")
- config: str = Field(..., description="Label Studio configuration")
- created_at: datetime = Field(..., description="Project creation timestamp")
- task_count: int = Field(default=0, description="Number of tasks in project")
-
- class Config:
- json_schema_extra = {
- "example": {
- "id": "proj_123abc",
- "name": "Image Classification Project",
- "description": "Classify images into categories",
- "config": "<View><Image name='image' value='$image'/></View>",
- "created_at": "2024-01-12T10:30:00",
- "task_count": 5
- }
- }
|