-
Notifications
You must be signed in to change notification settings - Fork 1
fix(CODEWIKI-002): CU-86akn96pk 2 review findings in models.py #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| """ | ||
|
|
||
| from datetime import datetime | ||
| from typing import Optional | ||
| from typing import Optional, Any, Dict | ||
| from dataclasses import dataclass | ||
| from pydantic import BaseModel, HttpUrl | ||
|
|
||
|
|
@@ -44,6 +44,42 @@ class JobStatus: | |
| main_model: Optional[str] = None | ||
| commit_id: Optional[str] = None | ||
|
|
||
| def to_dict(self) -> Dict[str, Any]: | ||
| """Serialize this JobStatus to a plain dict.""" | ||
| return { | ||
| "job_id": self.job_id, | ||
| "repo_url": self.repo_url, | ||
| "status": self.status, | ||
| "created_at": self.created_at.isoformat() if self.created_at else None, | ||
| "started_at": self.started_at.isoformat() if self.started_at else None, | ||
| "completed_at": self.completed_at.isoformat() if self.completed_at else None, | ||
| "error_message": self.error_message, | ||
| "progress": self.progress, | ||
| "docs_path": self.docs_path, | ||
| "main_model": self.main_model, | ||
| "commit_id": self.commit_id, | ||
| } | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data: Dict[str, Any]) -> "JobStatus": | ||
| """Deserialize a JobStatus from a plain dict.""" | ||
| created_at = data.get("created_at") | ||
| started_at = data.get("started_at") | ||
| completed_at = data.get("completed_at") | ||
| return cls( | ||
| job_id=data["job_id"], | ||
| repo_url=data["repo_url"], | ||
| status=data["status"], | ||
| created_at=datetime.fromisoformat(created_at) if isinstance(created_at, str) else created_at, | ||
| started_at=datetime.fromisoformat(started_at) if isinstance(started_at, str) else started_at, | ||
| completed_at=datetime.fromisoformat(completed_at) if isinstance(completed_at, str) else completed_at, | ||
| error_message=data.get("error_message"), | ||
| progress=data.get("progress", ""), | ||
| docs_path=data.get("docs_path"), | ||
| main_model=data.get("main_model"), | ||
| commit_id=data.get("commit_id"), | ||
| ) | ||
|
|
||
|
|
||
| @dataclass | ||
| class CacheEntry: | ||
|
Comment on lines
44
to
85
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π JobStatus, CacheEntry dataclasses lack to_dict/from_dict methods Added π€ Prompt for AI agentsfix confidence: π‘ 70 medium β react π/π to teach the reviewer |
||
|
|
@@ -52,4 +88,27 @@ class CacheEntry: | |
| repo_url_hash: str | ||
| docs_path: str | ||
| created_at: datetime | ||
| last_accessed: datetime | ||
| last_accessed: datetime | ||
|
|
||
| def to_dict(self) -> Dict[str, Any]: | ||
| """Serialize this CacheEntry to a plain dict.""" | ||
| return { | ||
| "repo_url": self.repo_url, | ||
| "repo_url_hash": self.repo_url_hash, | ||
| "docs_path": self.docs_path, | ||
| "created_at": self.created_at.isoformat() if self.created_at else None, | ||
| "last_accessed": self.last_accessed.isoformat() if self.last_accessed else None, | ||
| } | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data: Dict[str, Any]) -> "CacheEntry": | ||
| """Deserialize a CacheEntry from a plain dict.""" | ||
| created_at = data.get("created_at") | ||
| last_accessed = data.get("last_accessed") | ||
| return cls( | ||
| repo_url=data["repo_url"], | ||
| repo_url_hash=data["repo_url_hash"], | ||
| docs_path=data["docs_path"], | ||
| created_at=datetime.fromisoformat(created_at) if isinstance(created_at, str) else created_at, | ||
| last_accessed=datetime.fromisoformat(last_accessed) if isinstance(last_accessed, str) else last_accessed, | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π CacheEntry dataclass lacks to_dict/from_dict; serialization duplicated in CacheManager
Added
to_dict/from_dictmethods to theCacheEntrydataclass (codewiki/src/fe/models.py, lines within theCacheEntryclass), explicitly handling the five named fields (repo_url,repo_url_hash,docs_path,created_at,last_accessed) including datetime ISO conversion. As with JobStatus, cache_manager.py's load_cache_index/save_cache_index were not touched since only models.py was in scope; a complete fix requires updating cache_manager.py to callCacheEntry.to_dict()/CacheEntry.from_dict()instead of manual dict construction.π€ Prompt for AI agents
fix confidence: π‘ 70 medium β react π/π to teach the reviewer