Thibaut's picture
Add complete metrics evaluation subproject structure
b7d2408
"""CVAT API list request and response schemas.
This module contains Pydantic models for CVAT API list/filter operations,
including request parameters and paginated responses.
"""
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict
from .job import CvatApiJobRead
class CvatApiJobsListRequest(BaseModel):
"""Represents the request parameters for listing jobs.
This model is used to construct query parameters for the /api/jobs endpoint.
All fields are optional to allow flexible filtering.
Attributes:
task_id: Filter by task ID
project_id: Filter by project ID
stage: Filter by workflow stage
state: Filter by job state
type: Filter by job type (default: "annotation")
assignee: Filter by assignee username
dimension: Filter by dimension ("2d" or "3d")
filter: Custom filter expression
org: Filter by organization name
org_id: Filter by organization ID
page: Page number for pagination
page_size: Number of results per page
parent_job_id: Filter by parent job ID
project_name: Filter by project name
search: Search query string
sort: Sort order specification
task_name: Filter by task name
"""
task_id: int | None = None
project_id: int | None = None
stage: Literal["annotation", "validation", "acceptance"] | None = None
state: Literal["new", "in progress", "completed", "rejected"] | None = None
type: Literal["annotation", "ground_truth", "consensus_replica"] = "annotation"
assignee: str | None = None
dimension: Literal["2d", "3d"] | None = None
filter: str | None = None
org: str | None = None
org_id: int | None = None
page: int | None = None
page_size: int | None = None
parent_job_id: int | None = None
project_name: str | None = None
search: str | None = None
sort: str | None = None
task_name: str | None = None
model_config = ConfigDict(extra="allow")
def to_query_params(self) -> dict[str, Any]:
"""Convert the request model to query parameters, excluding None values.
Returns:
Dictionary of query parameters with non-None values
"""
params = {}
for field_name, field_value in self.model_dump().items():
if field_value is not None:
params[field_name] = field_value
return params
class CvatApiJobsListResponse(BaseModel):
"""Represents the paginated response for listing jobs.
This is the response model from the /api/jobs endpoint.
Attributes:
count: Total number of jobs matching the filter
next: URL for the next page of results (optional)
previous: URL for the previous page of results (optional)
results: List of jobs in the current page
"""
count: int
next: str | None = None
previous: str | None = None
results: list[CvatApiJobRead]
model_config = ConfigDict(extra="allow")