Skip to content

Cognition integration provider #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 18 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions alembic/versions/29933f2b894d_adds_integration_providers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""adds integration providers

Revision ID: 29933f2b894d
Revises: eb96f9b82cc1
Create Date: 2025-05-20 09:30:01.172135

"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "29933f2b894d"
down_revision = "eb96f9b82cc1"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"integration_access",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("integration_types", sa.ARRAY(sa.String()), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(
["organization_id"], ["organization.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)
op.create_index(
op.f("ix_cognition_integration_access_organization_id"),
"integration_access",
["organization_id"],
unique=False,
schema="cognition",
)
op.create_table(
"integration",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("name", sa.String(), nullable=True),
sa.Column("description", sa.String(), nullable=True),
sa.Column("tokenizer", sa.String(), nullable=True),
sa.Column("state", sa.String(), nullable=True),
sa.Column("type", sa.String(), nullable=True),
sa.Column("config", sa.JSON(), nullable=True),
sa.Column("llm_config", sa.JSON(), nullable=True),
sa.Column("error_message", sa.String(), nullable=True),
sa.Column("extract_history", sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(["project_id"], ["project.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)
op.create_index(
op.f("ix_cognition_integration_project_id"),
"integration",
["project_id"],
unique=False,
schema="cognition",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(
op.f("ix_cognition_integration_project_id"),
table_name="integration",
schema="cognition",
)
op.drop_table("integration", schema="cognition")
op.drop_index(
op.f("ix_cognition_integration_access_organization_id"),
table_name="integration_access",
schema="cognition",
)
op.drop_table("integration_access", schema="cognition")
# ### end Alembic commands ###
12 changes: 12 additions & 0 deletions controller/monitor/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,15 @@ def cancel_parse_cognition_file_task(
transformation_key,
with_commit=True,
)


def cancel_integration_task(
task_info: Dict[str, Any],
) -> None:

integration_id = task_info.get("integrationId")

task_monitor.set_integration_task_to_failed(
integration_id,
with_commit=True,
)
2 changes: 2 additions & 0 deletions fast_api/routes/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def cancel_task(
controller_manager.cancel_parse_cognition_file_task(
task_entity.organization_id, task_info
)
elif task_type == enums.TaskType.INTEGRATION.value:
controller_manager.cancel_integration_task(task_info)
else:
raise ValueError(f"{task_type} is no valid task type")

Expand Down