Skip to content

Commit 9ddadfd

Browse files
JWittmeyerandhreljaKernlumburovskalina
authored
Remove gates (#253)
* Remove gates * remove refinery pat * New alembic * New alembic * shema change * fix: schema update in downgrade step * Removal of crowd labeler and zeroshot (#254) * Removal of crowd labeler and zeroshot * Remove zero-shot unused code * Removed model callbacks * Removed model callbacks on data browser and filters * Model callback removal * Users filter removed on data browser * Removed label studio * Remove doc_ock from refinery * Removed dummy alembic test code * Submodule change --------- Co-authored-by: andhreljaKern <[email protected]> Co-authored-by: lumburovskalina <[email protected]>
1 parent 1e92112 commit 9ddadfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+159
-2581
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
"""Remove refinery token table
2+
3+
Revision ID: 414c990688f3
4+
Revises: 3e59ce51739c
5+
Create Date: 2024-09-09 09:25:36.796509
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '414c990688f3'
14+
down_revision = '3e59ce51739c'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
# generated code
22+
op.drop_index('ix_personal_access_token_project_id', table_name='personal_access_token')
23+
op.drop_index('ix_personal_access_token_user_id', table_name='personal_access_token')
24+
op.drop_table('personal_access_token')
25+
26+
op.drop_index('ix_cognition_project_refinery_question_project_id', table_name='project', schema='cognition')
27+
op.drop_index('ix_cognition_project_refinery_references_project_id', table_name='project', schema='cognition')
28+
op.drop_index('ix_cognition_project_refinery_relevance_project_id', table_name='project', schema='cognition')
29+
op.drop_constraint('project_refinery_references_project_id_fkey', 'project', schema='cognition', type_='foreignkey')
30+
op.drop_constraint('project_refinery_question_project_id_fkey', 'project', schema='cognition', type_='foreignkey')
31+
op.drop_constraint('project_refinery_relevance_project_id_fkey', 'project', schema='cognition', type_='foreignkey')
32+
op.drop_column('project', 'refinery_references_project_id', schema='cognition')
33+
op.drop_column('project', 'refinery_synchronization_interval_option', schema='cognition')
34+
op.drop_column('project', 'refinery_question_project_id', schema='cognition')
35+
op.drop_column('project', 'refinery_relevance_project_id', schema='cognition')
36+
op.drop_column('project', 'execute_query_enrichment_if_source_code', schema='cognition')
37+
38+
op.drop_index('ix_cognition_refinery_synchronization_task_cognition_project_id', table_name='refinery_synchronization_task', schema='cognition')
39+
op.drop_index('ix_cognition_refinery_synchronization_task_created_by', table_name='refinery_synchronization_task', schema='cognition')
40+
op.drop_index('ix_cognition_refinery_synchronization_task_refinery_project_id', table_name='refinery_synchronization_task', schema='cognition')
41+
op.drop_table('refinery_synchronization_task', schema='cognition')
42+
43+
# ### end Alembic commands ###
44+
45+
46+
def downgrade():
47+
# ### commands auto generated by Alembic - please adjust! ###
48+
49+
# ------------------------ pat remove ------------------------
50+
op.create_table('personal_access_token',
51+
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
52+
sa.Column('project_id', postgresql.UUID(), autoincrement=False, nullable=True),
53+
sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=True),
54+
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
55+
sa.Column('scope', sa.VARCHAR(), autoincrement=False, nullable=True),
56+
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
57+
sa.Column('expires_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
58+
sa.Column('last_used', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
59+
sa.Column('token', sa.VARCHAR(), autoincrement=False, nullable=True),
60+
sa.ForeignKeyConstraint(['project_id'], ['project.id'], name='personal_access_token_project_id_fkey', ondelete='CASCADE'),
61+
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='personal_access_token_user_id_fkey', ondelete='CASCADE'),
62+
sa.PrimaryKeyConstraint('id', name='personal_access_token_pkey')
63+
)
64+
op.create_index('ix_personal_access_token_user_id', 'personal_access_token', ['user_id'], unique=False)
65+
op.create_index('ix_personal_access_token_project_id', 'personal_access_token', ['project_id'], unique=False)
66+
67+
# ------------------------ cognition table fields ------------------------
68+
69+
op.add_column('project', sa.Column('execute_query_enrichment_if_source_code', sa.VARCHAR(), autoincrement=False, nullable=True), schema='cognition')
70+
op.add_column('project', sa.Column('refinery_relevance_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition')
71+
op.add_column('project', sa.Column('refinery_question_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition')
72+
op.add_column('project', sa.Column('refinery_synchronization_interval_option', sa.VARCHAR(), autoincrement=False, nullable=True), schema='cognition')
73+
op.add_column('project', sa.Column('refinery_references_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition')
74+
op.create_foreign_key('project_refinery_relevance_project_id_fkey', 'project', 'project', ['refinery_relevance_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL')
75+
op.create_foreign_key('project_refinery_question_project_id_fkey', 'project', 'project', ['refinery_question_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL')
76+
op.create_foreign_key('project_refinery_references_project_id_fkey', 'project', 'project', ['refinery_references_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL')
77+
op.create_index('ix_cognition_project_refinery_relevance_project_id', 'project', ['refinery_relevance_project_id'], unique=False, schema='cognition')
78+
op.create_index('ix_cognition_project_refinery_references_project_id', 'project', ['refinery_references_project_id'], unique=False, schema='cognition')
79+
op.create_index('ix_cognition_project_refinery_question_project_id', 'project', ['refinery_question_project_id'], unique=False, schema='cognition')
80+
81+
# ------------------------ sync table ------------------------
82+
83+
op.create_table('refinery_synchronization_task',
84+
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
85+
sa.Column('cognition_project_id', postgresql.UUID(), autoincrement=False, nullable=True),
86+
sa.Column('refinery_project_id', postgresql.UUID(), autoincrement=False, nullable=True),
87+
sa.Column('created_by', postgresql.UUID(), autoincrement=False, nullable=True),
88+
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
89+
sa.Column('finished_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
90+
sa.Column('state', sa.VARCHAR(), autoincrement=False, nullable=True),
91+
sa.Column('logs', postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=True),
92+
sa.Column('num_records_created', sa.INTEGER(), autoincrement=False, nullable=True),
93+
sa.ForeignKeyConstraint(['cognition_project_id'], ['cognition.project.id'], name='refinery_synchronization_task_cognition_project_id_fkey', ondelete='CASCADE'),
94+
sa.ForeignKeyConstraint(['created_by'], ['user.id'], name='refinery_synchronization_task_created_by_fkey', ondelete='CASCADE'),
95+
sa.ForeignKeyConstraint(['refinery_project_id'], ['project.id'], name='refinery_synchronization_task_refinery_project_id_fkey', ondelete='CASCADE'),
96+
sa.PrimaryKeyConstraint('id', name='refinery_synchronization_task_pkey'),
97+
schema='cognition'
98+
)
99+
op.create_index('ix_cognition_refinery_synchronization_task_refinery_project_id', 'refinery_synchronization_task', ['refinery_project_id'], unique=False, schema='cognition')
100+
op.create_index('ix_cognition_refinery_synchronization_task_created_by', 'refinery_synchronization_task', ['created_by'], unique=False, schema='cognition')
101+
op.create_index('ix_cognition_refinery_synchronization_task_cognition_project_id', 'refinery_synchronization_task', ['cognition_project_id'], unique=False, schema='cognition')
102+
103+
# ### end Alembic commands ###

api/project.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
from controller.attribute import manager as attribute_manager
88
from submodules.model import exceptions
99

10-
from submodules.model import events
11-
from util import doc_ock, notification, adapter
12-
13-
from controller.task_master import manager as task_master_manager
14-
from submodules.model.enums import TaskType, RecordTokenizationScope
15-
1610
logging.basicConfig(level=logging.DEBUG)
1711

1812

@@ -48,54 +42,3 @@ def get(self, request) -> JSONResponse:
4842
"knowledge_base_ids": [str(list.id) for list in project.knowledge_bases],
4943
}
5044
return JSONResponse(result)
51-
52-
53-
class ProjectCreationFromWorkflow(HTTPEndpoint):
54-
async def post(self, request_body) -> JSONResponse:
55-
(
56-
user_id,
57-
name,
58-
description,
59-
tokenizer,
60-
store_id,
61-
) = await adapter.unpack_request_body(request_body)
62-
63-
user = auth_manager.get_user_by_id(user_id)
64-
organization = auth_manager.get_organization_by_user_id(user.id)
65-
66-
project = project_manager.create_project(
67-
str(organization.id), name, description, user.id
68-
)
69-
project_manager.update_project(project_id=project.id, tokenizer=tokenizer)
70-
data = adapter.get_records_from_store(store_id)
71-
adapter.check(data, project.id, user.id)
72-
73-
project_manager.add_workflow_store_data_to_project(
74-
user_id=user.id,
75-
project_id=project.id,
76-
org_id=project.organization_id,
77-
file_name=name,
78-
data=data,
79-
)
80-
81-
task_master_manager.queue_task(
82-
str(organization.id),
83-
str(user.id),
84-
TaskType.TOKENIZATION,
85-
{
86-
"scope": RecordTokenizationScope.PROJECT.value,
87-
"include_rats": True,
88-
"only_uploaded_attributes": False,
89-
"project_id": str(project.id),
90-
},
91-
)
92-
93-
notification.send_organization_update(
94-
project.id, f"project_created:{str(project.id)}", True
95-
)
96-
doc_ock.post_event(
97-
str(user.id),
98-
events.CreateProject(Name=f"{name}-{project.id}", Description=description),
99-
)
100-
101-
return JSONResponse({"project_id": str(project.id)})

api/transfer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from starlette.responses import PlainTextResponse, JSONResponse
77
from controller.embedding.manager import recreate_embeddings
88

9-
from controller.transfer.labelstudio import import_preperator
109
from controller.transfer.cognition import (
1110
import_preparator as cognition_preparator,
1211
import_wizard as cognition_import_wizard,
@@ -244,6 +243,9 @@ def put(self, request) -> PlainTextResponse:
244243

245244
class AssociationsImport(HTTPEndpoint):
246245
async def post(self, request) -> JSONResponse:
246+
# Will be removed as part of the python sdk removal
247+
return JSONResponse({"error": "Not supported anymore"}, status_code=404)
248+
247249
project_id = request.path_params["project_id"]
248250
request_body = await request.json()
249251
user_id = request_body["user_id"]
@@ -298,9 +300,6 @@ def init_file_import(task: UploadTask, project_id: str, is_global_update: bool)
298300
if "records" in task.file_type:
299301
if task.upload_type == enums.UploadTypes.COGNITION.value:
300302
cognition_preparator.prepare_cognition_import(project_id, task)
301-
elif task.upload_type == enums.UploadTypes.LABEL_STUDIO.value:
302-
# deprecated
303-
import_preperator.prepare_label_studio_import(project_id, task)
304303
else:
305304
transfer_manager.import_records_from_file(project_id, task)
306305
daemon.run(

app.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from api.healthcheck import Healthcheck
55
from starlette.middleware import Middleware
66
from api.misc import IsDemoRest, IsManagedRest
7-
from api.project import ProjectDetails, ProjectCreationFromWorkflow
7+
from api.project import ProjectDetails
88
from api.transfer import (
99
AssociationsImport,
1010
FileExport,
@@ -21,7 +21,6 @@
2121
from fast_api.routes.project_setting import router as project_setting_router
2222
from fast_api.routes.misc import router as misc_router
2323
from fast_api.routes.comment import router as comment_router
24-
from fast_api.routes.zero_shot import router as zero_shot_router
2524
from fast_api.routes.attribute import router as attribute_router
2625
from fast_api.routes.embedding import router as embedding_router
2726
from fast_api.routes.notification import router as notification_router
@@ -47,7 +46,6 @@
4746
PREFIX_PROJECT_SETTING,
4847
PREFIX_MISC,
4948
PREFIX_COMMENT,
50-
PREFIX_ZERO_SHOT,
5149
PREFIX_ATTRIBUTE,
5250
PREFIX_EMBEDDING,
5351
PREFIX_NOTIFICATION,
@@ -79,9 +77,6 @@
7977
)
8078
fastapi_app.include_router(misc_router, prefix=PREFIX_MISC, tags=["misc"])
8179
fastapi_app.include_router(comment_router, prefix=PREFIX_COMMENT, tags=["comment"])
82-
fastapi_app.include_router(
83-
zero_shot_router, prefix=PREFIX_ZERO_SHOT, tags=["zero-shot"]
84-
)
8580
fastapi_app.include_router(
8681
attribute_router, prefix=PREFIX_ATTRIBUTE, tags=["attribute"]
8782
)
@@ -139,7 +134,6 @@
139134
CognitionPrepareProject,
140135
),
141136
Route("/project/{project_id:str}/import/task/{task_id:str}", UploadTaskInfo),
142-
Route("/project", ProjectCreationFromWorkflow),
143137
Route("/is_managed", IsManagedRest),
144138
Route("/is_demo", IsDemoRest),
145139
Mount("/api", app=fastapi_app, name="REST API"),

controller/embedding/manager.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,26 @@ def get_recommended_encoders(is_managed: bool) -> List[Any]:
5050
else:
5151
existing_models = []
5252
for model in existing_models:
53-
if not model["zero_shot_pipeline"]:
54-
not_yet_known = (
55-
len(
56-
list(
57-
filter(
58-
lambda rec: rec["config_string"] == model["name"],
59-
recommendations,
60-
)
53+
not_yet_known = (
54+
len(
55+
list(
56+
filter(
57+
lambda rec: rec["config_string"] == model["name"],
58+
recommendations,
6159
)
6260
)
63-
== 0
6461
)
65-
if not_yet_known:
66-
recommendations.append(
67-
{
68-
"config_string": model["name"],
69-
"description": "User downloaded model",
70-
"tokenizers": ["all"],
71-
"applicability": {"attribute": True, "token": True},
72-
}
73-
)
62+
== 0
63+
)
64+
if not_yet_known:
65+
recommendations.append(
66+
{
67+
"config_string": model["name"],
68+
"description": "User downloaded model",
69+
"tokenizers": ["all"],
70+
"applicability": {"attribute": True, "token": True},
71+
}
72+
)
7473
return recommendations
7574

7675

controller/gates/__init__.py

Whitespace-only changes.

controller/gates/gates_service.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)