Download projects/dataset_verification/models.py from api-relay/api_relay: direct link, hf CLI and curl.
- Browser
- Download file 4.72 kB
-
https://huggingface.co/spaces/api-relay/api_relay/resolve/main/projects/dataset_verification/models.py
- Command line
-
hf download hf://spaces/api-relay/api_relay/projects/dataset_verification/models.py
-
curl -L -o models.py https://huggingface.co/spaces/api-relay/api_relay/resolve/main/projects/dataset_verification/models.py
4.72 kB
| """Relay v4 models β one clean contract, no artificial caps. | |
| Concepts | |
| -------- | |
| Batch β every submission is a batch; the batch as a whole gets one id. | |
| Job β one example (multi-file, shared env, steps). Expanded server-side into | |
| *cells* when it carries a matrix (platform Γ runtime Γ stdin_cases). | |
| Cell β the executable unit (a row in the index). job_id = "<job_id>#<cell>". | |
| Step β a command sequence executed in the SAME workdir/venv, in order | |
| (cross-example dependency, e.g. "create file" β "read it"). | |
| Artifact β any file produced under outputs/ β images, audio, logs, binaries. | |
| Stored on disk, downloaded by agents via streaming GET (no base64 bloat). | |
| """ | |
| from typing import Dict, List, Literal, Optional | |
| from pydantic import BaseModel, Field | |
| SCHEMA = 4 | |
| class JobStep(BaseModel): | |
| name: str | |
| entry_point: str | |
| timeout: float = 60 | |
| dependencies: List[str] = Field(default_factory=list) # pip installs before this step | |
| class JobMatrix(BaseModel): | |
| platforms: List[str] = Field(default_factory=list) # e.g. ["linux", "windows", "macos"] | |
| runtimes: List[str] = Field(default_factory=list) # e.g. ["python-3.11", "python-3.13", "node-22"] | |
| stdin_cases: List[str] = Field(default_factory=list) # e.g. ["1 2\n", "3 4 5\n"] | |
| class JobSubmission(BaseModel): | |
| job_id: Optional[str] = None | |
| platform: str # base platform (used if matrix.platforms empty) | |
| runtime: str # base runtime tag (used if matrix.runtimes empty) | |
| files: Dict[str, str] = Field(default_factory=dict) # base files {relpath: text} | |
| files_variants: Dict[str, Dict[str, str]] = Field(default_factory=dict) # platform -> overlay files | |
| entry_point: Optional[str] = None # single-step compat | |
| steps: Optional[List[JobStep]] = None # preferred: shared env, sequential | |
| dependencies: List[str] = Field(default_factory=list) | |
| network_required: bool = False | |
| stdin: Optional[str] = None | |
| matrix: Optional[JobMatrix] = None | |
| timeout: float = 60 # per step unless step overrides | |
| stop_on_failure: bool = True | |
| class BatchSubmission(BaseModel): | |
| batch_id: Optional[str] = None | |
| jobs: List[JobSubmission] = Field(default_factory=list) | |
| class WorkerRegisterRequest(BaseModel): | |
| worker_id: int | |
| url: str # primary url: runner://<os>/<uuid> or pull:// token | |
| urls: Optional[List[str]] = None # optional tunnel redundancy: tried in order | |
| environment: "Environment" | |
| class Environment(BaseModel): | |
| platform: str | |
| os_version: str | |
| runtimes: List[str] # runtime tags this runner can execute | |
| max_concurrent_jobs: int = 4 | |
| notes: Optional[str] = None | |
| class ResultObject(BaseModel): | |
| job_id: str # cell id: "<base>#<cell>" | |
| exit_code: int | |
| timed_out: bool | |
| category: Literal["success", "timeout", "dependency_install_failed", | |
| "infra_failure", "checker_error", "not_applicable"] | |
| steps: List[Dict] = Field(default_factory=list) # per-step {name,stdout,stderr,exit_code,timed_out} | |
| filesystem_state: Optional[Dict[str, str]] = None # relpath -> "sha256:.." | "b64:.." | |
| artifacts: List[Dict] = Field(default_factory=list) # artifact refs declared by runner | |
| failure_reason: Optional[str] = None | |
| WorkerRegisterRequest.model_rebuild() | |
| # ---- internal index row (never serialized to callers) ---- | |
| class JobMeta(BaseModel): | |
| job_id: str # cell id | |
| base_job_id: str # original job_id from the batch | |
| batch_id: str | |
| cell: str # e.g. "linux/python-3.12/case-1" or "base" | |
| platform: str | |
| runtime: str | |
| timeout: float | |
| status: str = "queued" # queued | claimed | complete | |
| submitted_at: float | |
| retry_count: int = 0 | |
| claimed_by: Optional[int] = None | |
| claimed_worker_url: Optional[str] = None | |
| claimed_at: Optional[float] = None | |
| claim_deadline: Optional[float] = None | |
| completed_at: Optional[float] = None | |
| last_abandon_reason: Optional[str] = None | |
| stdin_case: Optional[int] = None | |
| # ---- artifact metadata (stored in artifacts/<id>.json; bytes in artifacts/<id>.bin) ---- | |
| class ArtifactMeta(BaseModel): | |
| artifact_id: str | |
| batch_id: str | |
| job_id: str # cell id | |
| path: str # path inside the job workdir | |
| kind: str # image | audio | file | |
| content_type: str | |
| size: int | |
| sha256: str | |
| created_at: float | |