Download models.py from smlflg/StudyAgent: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/smlflg/StudyAgent/resolve/main/models.py
- Command line
-
hf download hf://smlflg/StudyAgent/models.py
-
curl -L -o models.py https://huggingface.co/smlflg/StudyAgent/resolve/main/models.py
2.65 kB
| import enum | |
| from datetime import datetime, timezone | |
| from sqlalchemy import Boolean, Column, DateTime, Enum, ForeignKey, Integer, String, Text | |
| from sqlalchemy.orm import relationship | |
| from database import Base | |
| class MicroStepStatus(enum.Enum): | |
| pending = "pending" | |
| in_progress = "in_progress" | |
| completed = "completed" | |
| skipped = "skipped" | |
| class Subject(Base): | |
| __tablename__ = "subjects" | |
| id = Column(Integer, primary_key=True, index=True) | |
| name = Column(String(200), nullable=False) | |
| semester = Column(String(50)) | |
| is_active = Column(Boolean, default=True) | |
| is_parked = Column(Boolean, default=False) | |
| created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None)) | |
| deadlines = relationship("Deadline", back_populates="subject", cascade="all, delete-orphan") | |
| study_sessions = relationship("StudySession", back_populates="subject", cascade="all, delete-orphan") | |
| class Deadline(Base): | |
| __tablename__ = "deadlines" | |
| id = Column(Integer, primary_key=True, index=True) | |
| subject_id = Column(Integer, ForeignKey("subjects.id"), nullable=False) | |
| title = Column(String(200), nullable=False) | |
| description = Column(Text) | |
| due_date = Column(DateTime, nullable=False) | |
| created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None)) | |
| subject = relationship("Subject", back_populates="deadlines") | |
| micro_steps = relationship("MicroStep", back_populates="deadline", cascade="all, delete-orphan") | |
| class MicroStep(Base): | |
| __tablename__ = "micro_steps" | |
| id = Column(Integer, primary_key=True, index=True) | |
| deadline_id = Column(Integer, ForeignKey("deadlines.id"), nullable=False) | |
| title = Column(String(300), nullable=False) | |
| context = Column(Text) # what exactly to do — fresh-start framing | |
| order_num = Column(Integer, default=0) | |
| duration_minutes = Column(Integer, default=5) | |
| status = Column(Enum(MicroStepStatus), default=MicroStepStatus.pending) | |
| created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None)) | |
| deadline = relationship("Deadline", back_populates="micro_steps") | |
| class StudySession(Base): | |
| __tablename__ = "study_sessions" | |
| id = Column(Integer, primary_key=True, index=True) | |
| subject_id = Column(Integer, ForeignKey("subjects.id"), nullable=False) | |
| started_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None)) | |
| ended_at = Column(DateTime) | |
| steps_completed = Column(Integer, default=0) | |
| notes = Column(Text) | |
| subject = relationship("Subject", back_populates="study_sessions") | |