Spaces:
Running on Zero
Running on Zero
File size: 1,657 Bytes
5f7afef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """Data models for CodeStar Judge API and statistics."""
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
class JudgeTaskStatus(str, Enum):
QUEUED = "queued"
RUNNING = "running"
WAKING_UP = "waking_up"
COMPLETED = "completed"
NETWORK_FAILED = "network_failed"
class AsyncJudgeRequest(BaseModel):
problem_slug: str = Field(..., max_length=128)
code: str = Field(..., max_length=65536)
custom_testcase: Optional[str] = Field(None, max_length=16384)
is_test: bool = False
class AsyncJudgeSubmitResponse(BaseModel):
task_id: str
status: str = "queued"
created_at: str
class AsyncJudgeResult(BaseModel):
status: str
passed: int
total: int
execution_time_ms: float
peak_memory_mb: float
beat_time_percent: Optional[float] = None
beat_memory_percent: Optional[float] = None
message: str
passed_count: Optional[int] = None
total_count: Optional[int] = None
beats_runtime_pct: Optional[float] = None
beats_memory_pct: Optional[float] = None
cases: Optional[List[Dict[str, Any]]] = None
stdout: Optional[str] = None
class AsyncJudgeTaskResponse(BaseModel):
task_id: str
status: str
result: Optional[Dict[str, Any]] = None
error: Optional[str] = None
class ProblemStats(BaseModel):
slug: str
total_submissions: int
accepted_submissions: int
pass_rate: Optional[float] = None
has_sufficient_data: bool
display_pass_rate: str
execution_time_p50_ms: Optional[float] = None
peak_memory_p50_mb: Optional[float] = None
|