mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
Handle missing relevant_files.
This commit is contained in:
committed by
Senko Rašić
parent
5035f59390
commit
9334b6ef12
@@ -73,9 +73,11 @@ class Developer(BaseAgent):
|
||||
log.debug(f"Some files are missing descriptions: {', '.join(missing_descriptions)}, reqesting analysis")
|
||||
return AgentResponse.describe_files(self)
|
||||
|
||||
log.debug(f"Current state files: {len(self.current_state.files)}, relevant {self.current_state.relevant_files}")
|
||||
log.debug(
|
||||
f"Current state files: {len(self.current_state.files)}, relevant {self.current_state.relevant_files or []}"
|
||||
)
|
||||
# Check which files are relevant to the current task
|
||||
if self.current_state.files and not self.current_state.relevant_files:
|
||||
if self.current_state.files and self.current_state.relevant_files is None:
|
||||
await self.get_relevant_files()
|
||||
return AgentResponse.done(self)
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Make relevant_files nullable
|
||||
|
||||
Revision ID: f352dbe45751
|
||||
Revises: 0a1bb637fa26
|
||||
Create Date: 2024-06-04 15:07:40.175466
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "f352dbe45751"
|
||||
down_revision: Union[str, None] = "0a1bb637fa26"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("project_states", schema=None) as batch_op:
|
||||
batch_op.alter_column("relevant_files", existing_type=sqlite.JSON(), nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("project_states", schema=None) as batch_op:
|
||||
batch_op.alter_column("relevant_files", existing_type=sqlite.JSON(), nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -51,7 +51,7 @@ class ProjectState(Base):
|
||||
tasks: Mapped[list[dict]] = mapped_column(default=list)
|
||||
steps: Mapped[list[dict]] = mapped_column(default=list)
|
||||
iterations: Mapped[list[dict]] = mapped_column(default=list)
|
||||
relevant_files: Mapped[list[str]] = mapped_column(default=list)
|
||||
relevant_files: Mapped[Optional[list[str]]] = mapped_column(default=None)
|
||||
modified_files: Mapped[dict] = mapped_column(default=dict)
|
||||
run_command: Mapped[Optional[str]] = mapped_column()
|
||||
action: Mapped[Optional[str]] = mapped_column()
|
||||
@@ -167,7 +167,8 @@ class ProjectState(Base):
|
||||
|
||||
:return: List of tuples with file path and content.
|
||||
"""
|
||||
return [file for file in self.files if file.path in self.relevant_files]
|
||||
relevant = self.relevant_files or []
|
||||
return [file for file in self.files if file.path in relevant]
|
||||
|
||||
@staticmethod
|
||||
def create_initial_state(branch: "Branch") -> "ProjectState":
|
||||
@@ -361,6 +362,8 @@ class ProjectState(Base):
|
||||
|
||||
if path not in self.modified_files and not external:
|
||||
self.modified_files[path] = original_content
|
||||
|
||||
self.relevant_files = self.relevant_files or []
|
||||
if path not in self.relevant_files:
|
||||
self.relevant_files.append(path)
|
||||
|
||||
|
||||
@@ -80,14 +80,14 @@ async def test_create_next_deep_copies_fields(testdb):
|
||||
next_state.tasks[0]["completed"] = True
|
||||
next_state.iterations[0]["completed"] = True
|
||||
next_state.steps[0]["completed"] = True
|
||||
next_state.relevant_files.append("test.txt")
|
||||
next_state.relevant_files = ["test.txt"]
|
||||
next_state.modified_files["test.txt"] = "Hello World"
|
||||
|
||||
assert state.epics[0]["completed"] is False
|
||||
assert state.tasks[0]["completed"] is False
|
||||
assert state.iterations[0]["completed"] is False
|
||||
assert state.steps[0]["completed"] is False
|
||||
assert state.relevant_files == []
|
||||
assert state.relevant_files is None
|
||||
assert state.modified_files == {}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user