-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into del-folders-cli
- Loading branch information
Showing
146 changed files
with
2,586 additions
and
1,099 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"charliermarsh.ruff" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"editor.codeActionsOnSave": { | ||
"notebook.source.fixAll": "explicit", | ||
// uncomment this if you don't want the editor to automatically organize imports | ||
// "source.organizeImports": "never" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Revision ID: ac3933258035 | ||
Revises: 08bcb9a24d9b | ||
Create Date: 2024-08-22 20:34:37.547325 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'ac3933258035' | ||
down_revision: Union[str, None] = '08bcb9a24d9b' | ||
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! ### | ||
op.create_table('agent_tasks', | ||
sa.Column('agent_id', sa.String(), nullable=False), | ||
sa.Column('task_id', sa.String(), nullable=False), | ||
sa.Column('id', sa.String(), nullable=False), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.Column('updated_at', sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ondelete='CASCADE'), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('agent_id', 'task_id', name='unique_agent_task') | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('agent_tasks') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List | ||
|
||
from sqlalchemy.orm import Session | ||
|
||
from backend.database_models.agent_task import AgentTask, SyncCeleryTaskMeta | ||
from backend.services.logger.utils import LoggerFactory | ||
from backend.services.transaction import validate_transaction | ||
|
||
logger = LoggerFactory().get_logger() | ||
|
||
|
||
@validate_transaction | ||
def create_agent_task(db: Session, agent_id: str, task_id: str) -> AgentTask: | ||
agent_task = AgentTask(agent_id=agent_id, task_id=task_id) | ||
db.add(agent_task) | ||
db.commit() | ||
db.refresh(agent_task) | ||
return agent_task | ||
|
||
|
||
@validate_transaction | ||
def get_agent_tasks_by_agent_id(db: Session, agent_id: str) -> List[SyncCeleryTaskMeta]: | ||
return ( | ||
db.query(SyncCeleryTaskMeta) | ||
.join(AgentTask, AgentTask.task_id == SyncCeleryTaskMeta.task_id) | ||
.filter(AgentTask.agent_id == agent_id) | ||
.all() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from sqlalchemy import ( | ||
DateTime, | ||
ForeignKey, | ||
Integer, | ||
LargeBinary, | ||
String, | ||
Text, | ||
UniqueConstraint, | ||
) | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from backend.database_models.base import Base, MinimalBase | ||
|
||
|
||
class SyncCeleryTaskMeta(MinimalBase): | ||
__tablename__ = "sync_celery_taskmeta" | ||
|
||
id: Mapped[int] = mapped_column(Integer, primary_key=True) | ||
task_id: Mapped[str] = mapped_column(String(155), unique=True) | ||
status: Mapped[str] = mapped_column(String(50)) | ||
result: Mapped[bytes] = mapped_column(LargeBinary) | ||
date_done: Mapped[DateTime] = mapped_column(DateTime) | ||
traceback: Mapped[str] = mapped_column(Text) | ||
name: Mapped[str] = mapped_column(String(155)) | ||
args: Mapped[bytes] = mapped_column(LargeBinary) | ||
kwargs: Mapped[bytes] = mapped_column(LargeBinary) | ||
worker: Mapped[str] = mapped_column(String(155)) | ||
retries: Mapped[int] = mapped_column(Integer) | ||
queue: Mapped[str] = mapped_column(String(155)) | ||
|
||
|
||
class AgentTask(Base): | ||
__tablename__ = "agent_tasks" | ||
|
||
agent_id: Mapped[str] = mapped_column( | ||
ForeignKey("agents.id", ondelete="CASCADE"), nullable=False | ||
) | ||
|
||
task_id: Mapped[str] = mapped_column(nullable=False) | ||
|
||
__table_args__ = ( | ||
UniqueConstraint("agent_id", "task_id", name="unique_agent_task"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.