Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Fix pool size issue on DB
Browse files Browse the repository at this point in the history
  • Loading branch information
waynehamadi committed Aug 19, 2023
1 parent 75aa876 commit 30e1938
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions autogpt/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,16 @@ def __init__(self, database_string) -> None:
self.Session = sessionmaker(bind=self.engine)
print("Databases Created")

async def create_task(
self, input: Optional[str], additional_input: Optional[TaskInput] = None
) -> Task:
session = self.Session()
new_task = TaskModel(
input=input,
additional_input=additional_input.__root__ if additional_input else None,
)
session.add(new_task)
session.commit()
session.refresh(new_task)
return convert_to_task(new_task)
async def create_task(self, input: Optional[str], additional_input: Optional[TaskInput] = None) -> Task:
with self.Session() as session:
new_task = TaskModel(
input=input,
additional_input=additional_input.__root__ if additional_input else None,
)
session.add(new_task)
session.commit()
session.refresh(new_task)
return convert_to_task(new_task)

async def create_step(
self,
Expand Down Expand Up @@ -265,14 +263,14 @@ async def list_steps(self, task_id: str) -> List[Step]:
]

async def list_artifacts(self, task_id: str) -> List[Artifact]:
session = self.Session()
artifacts = session.query(ArtifactModel).filter_by(task_id=task_id).all()
return [
Artifact(
artifact_id=str(artifact.artifact_id),
file_name=artifact.file_name,
agent_created=artifact.agent_created,
uri=artifact.uri,
)
for artifact in artifacts
]
with self.Session() as session:
artifacts = session.query(ArtifactModel).filter_by(task_id=task_id).all()
return [
Artifact(
artifact_id=str(artifact.artifact_id),
file_name=artifact.file_name,
agent_created=artifact.agent_created,
uri=artifact.uri,
)
for artifact in artifacts
]

0 comments on commit 30e1938

Please sign in to comment.