mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-09 21:27:53 -05:00
Merge pull request #1015 from Pythagora-io/use-utc-exec-logs
Use UTC for started_at colum in exec_logs.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@@ -96,13 +96,13 @@ class Executor(BaseAgent):
|
|||||||
self.next_state.action = f'Skip "{cmd_name}"'
|
self.next_state.action = f'Skip "{cmd_name}"'
|
||||||
return AgentResponse.done(self)
|
return AgentResponse.done(self)
|
||||||
|
|
||||||
started_at = datetime.now()
|
started_at = datetime.now(timezone.utc)
|
||||||
|
|
||||||
log.info(f"Running command `{cmd}` with timeout {timeout}s")
|
log.info(f"Running command `{cmd}` with timeout {timeout}s")
|
||||||
status_code, stdout, stderr = await self.process_manager.run_command(cmd, timeout=timeout)
|
status_code, stdout, stderr = await self.process_manager.run_command(cmd, timeout=timeout)
|
||||||
llm_response = await self.check_command_output(cmd, timeout, stdout, stderr, status_code)
|
llm_response = await self.check_command_output(cmd, timeout, stdout, stderr, status_code)
|
||||||
|
|
||||||
duration = (datetime.now() - started_at).total_seconds()
|
duration = (datetime.now(timezone.utc) - started_at).total_seconds()
|
||||||
|
|
||||||
self.complete()
|
self.complete()
|
||||||
self.next_state.action = f'Run "{cmd_name}"'
|
self.next_state.action = f'Run "{cmd_name}"'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from uuid import UUID
|
|||||||
|
|
||||||
from sqlalchemy import ForeignKey, inspect
|
from sqlalchemy import ForeignKey, inspect
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
|
||||||
from core.db.models import Base
|
from core.db.models import Base
|
||||||
from core.proc.exec_log import ExecLog as ExecLogData
|
from core.proc.exec_log import ExecLog as ExecLogData
|
||||||
@@ -21,7 +22,7 @@ class ExecLog(Base):
|
|||||||
project_state_id: Mapped[Optional[UUID]] = mapped_column(ForeignKey("project_states.id", ondelete="SET NULL"))
|
project_state_id: Mapped[Optional[UUID]] = mapped_column(ForeignKey("project_states.id", ondelete="SET NULL"))
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
started_at: Mapped[datetime] = mapped_column()
|
started_at: Mapped[datetime] = mapped_column(server_default=func.now())
|
||||||
duration: Mapped[float] = mapped_column()
|
duration: Mapped[float] = mapped_column()
|
||||||
cmd: Mapped[str] = mapped_column()
|
cmd: Mapped[str] = mapped_column()
|
||||||
cwd: Mapped[str] = mapped_column()
|
cwd: Mapped[str] = mapped_column()
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
class ExecLog(BaseModel):
|
class ExecLog(BaseModel):
|
||||||
started_at: datetime = Field(default_factory=datetime.now)
|
started_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
||||||
duration: float = Field(description="The duration of the command/process run in seconds")
|
duration: float = Field(description="The duration of the command/process run in seconds")
|
||||||
cmd: str = Field(description="The full command (as executed in the shell)")
|
cmd: str = Field(description="The full command (as executed in the shell)")
|
||||||
cwd: str = Field(description="The working directory for the command (relative to project root)")
|
cwd: str = Field(description="The working directory for the command (relative to project root)")
|
||||||
|
|||||||
Reference in New Issue
Block a user