Spaces:
Sleeping
Sleeping
Download backend/models.py from notha99y/timetablev2: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/notha99y/timetablev2/resolve/main/backend/models.py
- Command line
-
hf download hf://spaces/notha99y/timetablev2/backend/models.py
-
curl -L -o models.py https://huggingface.co/spaces/notha99y/timetablev2/resolve/main/backend/models.py
1.2 kB
| from pydantic import BaseModel, validator | |
| from typing import List, Optional | |
| import re | |
| class ModuleData(BaseModel): | |
| module: str | |
| class_name: str | |
| lecture: str | |
| tutorial: str | |
| def validate_time_format(cls, v): | |
| if not v or v.strip() == '': | |
| return v | |
| # Temporarily relaxed validation - just check basic structure | |
| if ' to ' not in v.lower(): | |
| raise ValueError(f'Invalid time format: "{v}". Must contain "to" (e.g., "Mon 4.30pm to 6pm")') | |
| return v.strip() | |
| class SearchRequest(BaseModel): | |
| modules: List[ModuleData] | |
| num_combinations: int = 4 | |
| restrict_back_to_back: bool = False | |
| def validate_num_combinations(cls, v): | |
| if v < 1 or v > 20: | |
| raise ValueError('Number of combinations must be between 1 and 20') | |
| return v | |
| class CombinationResult(BaseModel): | |
| combination_id: int | |
| modules: List[ModuleData] | |
| schedule_grid: dict # Day -> time slots mapping | |
| class SearchResponse(BaseModel): | |
| success: bool | |
| combinations: List[CombinationResult] = [] | |
| message: str = "" | |
| error: Optional[str] = None |