Fix linting
This commit is contained in:
@@ -20,13 +20,14 @@ from lightrag.base import DocProcessingStatus, DocStatus
|
||||
from lightrag.api.utils_api import get_combined_auth_dependency
|
||||
from ..config import global_args
|
||||
|
||||
|
||||
# Function to format datetime to ISO format string with timezone information
|
||||
def format_datetime(dt: Any) -> Optional[str]:
|
||||
"""Format datetime to ISO format string with timezone information
|
||||
|
||||
|
||||
Args:
|
||||
dt: Datetime object, string, or None
|
||||
|
||||
|
||||
Returns:
|
||||
ISO format string with timezone information, or None if input is None
|
||||
"""
|
||||
@@ -34,16 +35,17 @@ def format_datetime(dt: Any) -> Optional[str]:
|
||||
return None
|
||||
if isinstance(dt, str):
|
||||
return dt
|
||||
|
||||
|
||||
# Check if datetime object has timezone information
|
||||
if isinstance(dt, datetime):
|
||||
# If datetime object has no timezone info (naive datetime), add UTC timezone
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=timezone.utc)
|
||||
|
||||
|
||||
# Return ISO format string with timezone information
|
||||
return dt.isoformat()
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/documents",
|
||||
tags=["documents"],
|
||||
@@ -338,7 +340,7 @@ class PipelineStatusResponse(BaseModel):
|
||||
history_messages: Optional[List[str]] = None
|
||||
update_status: Optional[dict] = None
|
||||
|
||||
@field_validator('job_start', mode='before')
|
||||
@field_validator("job_start", mode="before")
|
||||
@classmethod
|
||||
def parse_job_start(cls, value):
|
||||
"""Process datetime and return as ISO format string with timezone"""
|
||||
@@ -1263,12 +1265,8 @@ def create_document_routes(
|
||||
content_summary=doc_status.content_summary,
|
||||
content_length=doc_status.content_length,
|
||||
status=doc_status.status,
|
||||
created_at=format_datetime(
|
||||
doc_status.created_at
|
||||
),
|
||||
updated_at=format_datetime(
|
||||
doc_status.updated_at
|
||||
),
|
||||
created_at=format_datetime(doc_status.created_at),
|
||||
updated_at=format_datetime(doc_status.updated_at),
|
||||
chunks_count=doc_status.chunks_count,
|
||||
error=doc_status.error,
|
||||
metadata=doc_status.metadata,
|
||||
|
@@ -1028,7 +1028,7 @@ class PGDocStatusStorage(DocStatusStorage):
|
||||
# Remove timezone information, store utc time in db
|
||||
created_at = parse_datetime(v.get("created_at"))
|
||||
updated_at = parse_datetime(v.get("updated_at"))
|
||||
|
||||
|
||||
# chunks_count is optional
|
||||
await self.db.execute(
|
||||
sql,
|
||||
|
@@ -958,7 +958,9 @@ class LightRAG:
|
||||
"content_summary": status_doc.content_summary,
|
||||
"content_length": status_doc.content_length,
|
||||
"created_at": status_doc.created_at,
|
||||
"updated_at": datetime.now(timezone.utc).isoformat(),
|
||||
"updated_at": datetime.now(
|
||||
timezone.utc
|
||||
).isoformat(),
|
||||
"file_path": file_path,
|
||||
}
|
||||
}
|
||||
@@ -1018,7 +1020,9 @@ class LightRAG:
|
||||
"content_summary": status_doc.content_summary,
|
||||
"content_length": status_doc.content_length,
|
||||
"created_at": status_doc.created_at,
|
||||
"updated_at": datetime.now(timezone.utc).isoformat(),
|
||||
"updated_at": datetime.now(
|
||||
timezone.utc
|
||||
).isoformat(),
|
||||
"file_path": file_path,
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1057,9 @@ class LightRAG:
|
||||
"content_summary": status_doc.content_summary,
|
||||
"content_length": status_doc.content_length,
|
||||
"created_at": status_doc.created_at,
|
||||
"updated_at": datetime.now(timezone.utc).isoformat(),
|
||||
"updated_at": datetime.now(
|
||||
timezone.utc
|
||||
).isoformat(),
|
||||
"file_path": file_path,
|
||||
}
|
||||
}
|
||||
|
@@ -158,7 +158,7 @@ export default function PipelineStatusDialog({
|
||||
<div className="rounded-md border p-3 space-y-2">
|
||||
<div>{t('documentPanel.pipelineStatus.jobName')}: {status?.job_name || '-'}</div>
|
||||
<div className="flex justify-between">
|
||||
<span>{t('documentPanel.pipelineStatus.startTime')}: {status?.job_start
|
||||
<span>{t('documentPanel.pipelineStatus.startTime')}: {status?.job_start
|
||||
? new Date(status.job_start).toLocaleString(undefined, {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
@@ -166,7 +166,7 @@ export default function PipelineStatusDialog({
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
second: 'numeric'
|
||||
})
|
||||
})
|
||||
: '-'}</span>
|
||||
<span>{t('documentPanel.pipelineStatus.progress')}: {status ? `${status.cur_batch}/${status.batchs} ${t('documentPanel.pipelineStatus.unit')}` : '-'}</span>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user