Spaces:
Sleeping
Sleeping
Download api/schemas.py from ModhiSathvik/task-load-balancer: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/spaces/ModhiSathvik/task-load-balancer/resolve/main/api/schemas.py
- Command line
-
hf download hf://spaces/ModhiSathvik/task-load-balancer/api/schemas.py
-
curl -L -o schemas.py https://huggingface.co/spaces/ModhiSathvik/task-load-balancer/resolve/main/api/schemas.py
3.18 kB
| from pydantic import BaseModel, Field, validator | |
| from typing import Dict, List | |
| class TaskAssignment(BaseModel): | |
| developer_id: int = Field(..., ge=1, description="Developer ID") | |
| current_task_count: int = Field(..., ge=0, le=15) | |
| avg_completion_time_days: float = Field(..., ge=1.0, le=30.0) | |
| skill_match_score: int = Field(..., ge=0, le=100) | |
| total_story_points_assigned: int = Field(..., ge=0, le=50) | |
| recent_overtime_hours: int = Field(..., ge=0, le=25) | |
| task_switch_frequency: float = Field(..., ge=0.0, le=10.0) | |
| pr_review_pending: int = Field(..., ge=0, le=20) | |
| priority: int = Field(..., ge=0, le=3) | |
| estimated_story_points: int = Field(...) | |
| days_until_deadline: int = Field(..., ge=1, le=30) | |
| required_skill: str = Field(...) | |
| has_dependencies: int = Field(..., ge=0, le=1) | |
| task_type: int = Field(..., ge=0, le=2) | |
| team_size: int = Field(..., ge=5, le=20) | |
| sprint_days_remaining: int = Field(..., ge=1, le=14) | |
| team_avg_velocity: int = Field(..., ge=20, le=100) | |
| def validate_fibonacci(cls, v): | |
| allowed = [1, 2, 3, 5, 8, 13] | |
| if v not in allowed: | |
| raise ValueError(f'Story points must be one of {allowed}') | |
| return v | |
| def validate_skill(cls, v): | |
| allowed = ['frontend', 'backend', 'devops', 'ml', 'testing'] | |
| if v not in allowed: | |
| raise ValueError(f'Skill must be one of {allowed}') | |
| return v | |
| class Config: | |
| schema_extra = { | |
| "example": { | |
| "developer_id": 5, | |
| "current_task_count": 6, | |
| "avg_completion_time_days": 5.5, | |
| "skill_match_score": 85, | |
| "total_story_points_assigned": 21, | |
| "recent_overtime_hours": 8, | |
| "task_switch_frequency": 4.2, | |
| "pr_review_pending": 3, | |
| "priority": 1, | |
| "estimated_story_points": 5, | |
| "days_until_deadline": 7, | |
| "required_skill": "backend", | |
| "has_dependencies": 0, | |
| "task_type": 0, | |
| "team_size": 10, | |
| "sprint_days_remaining": 8, | |
| "team_avg_velocity": 55 | |
| } | |
| } | |
| class PredictionResponse(BaseModel): | |
| developer_id: int | |
| overload_risk: int | |
| risk_label: str | |
| confidence: float | |
| risk_probabilities: Dict[str, float] | |
| contributing_factors: List[str] | |
| recommendation: str | |
| class Config: | |
| schema_extra = { | |
| "example": { | |
| "developer_id": 5, | |
| "overload_risk": 1, | |
| "risk_label": "Yellow (Moderate)", | |
| "confidence": 0.68, | |
| "risk_probabilities": { | |
| "green": 0.25, | |
| "yellow": 0.68, | |
| "red": 0.07 | |
| }, | |
| "contributing_factors": [ | |
| "High task count (6)", | |
| "Recent overtime (8h)" | |
| ], | |
| "recommendation": "Proceed with caution. Monitor workload closely." | |
| } | |
| } | |