Skip to content

Removal of GraphQL Data Return Schema #284

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

Merged
merged 72 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
86d299f
projectByProjectId
LennartSchmidtKern Jan 6, 2025
62cf3e3
allProjects
LennartSchmidtKern Jan 6, 2025
a8ce0c5
labelDistribution, generalProjectStats
LennartSchmidtKern Jan 6, 2025
3d2836c
projectTokenization, modelProviderInfo
LennartSchmidtKern Jan 6, 2025
7eb216d
projectExportCredentials, uploadCredentialsAndId
LennartSchmidtKern Jan 6, 2025
02e487b
createSampleProject, updateProjectStatus, updateProjectTokenizer
LennartSchmidtKern Jan 6, 2025
e962593
createProject, deleteProject
LennartSchmidtKern Jan 6, 2025
0764996
uploadTaskById, updateProjectNameDescription
LennartSchmidtKern Jan 6, 2025
2a79ffc
attributes,embeddings, data slide
LennartSchmidtKern Jan 7, 2025
f9d1213
lt query rework
JWittmeyer Jan 7, 2025
5b7e02a
comment, data browser, heuristic
LennartSchmidtKern Jan 7, 2025
19aabc2
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 7, 2025
f19900c
labeling-tasks-by-project-id
LennartSchmidtKern Jan 7, 2025
8225236
labeling, lookup
LennartSchmidtKern Jan 7, 2025
06c0b22
fixes
LennartSchmidtKern Jan 7, 2025
5889f98
notifications, record, settings
LennartSchmidtKern Jan 7, 2025
95a1cdc
misc
LennartSchmidtKern Jan 7, 2025
4065a53
misc
LennartSchmidtKern Jan 7, 2025
6ca6097
First part org queries
JWittmeyer Jan 7, 2025
af0a724
More org endpoints
JWittmeyer Jan 8, 2025
a308512
More org changes
JWittmeyer Jan 8, 2025
0cd173b
allOrgs, user roles
LennartSchmidtKern Jan 8, 2025
6252935
another endpoint
JWittmeyer Jan 8, 2025
4403b51
perf: update organization endpoints to remove graphql syntax
andhreljaKern Jan 8, 2025
55369fc
info source
LennartSchmidtKern Jan 8, 2025
6e7daf9
perf: update organization endpoints to remove graphql syntax
andhreljaKern Jan 8, 2025
a90675f
silent success
LennartSchmidtKern Jan 8, 2025
bdec240
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 8, 2025
da1b72a
weak-supervision api change to silent success
anmarhindi Jan 9, 2025
e74016f
task_execution api change to silent success
anmarhindi Jan 9, 2025
7a7a96f
get silent success
LennartSchmidtKern Jan 9, 2025
1833d9c
Change sync-records usage of responses
anmarhindi Jan 9, 2025
cca5227
Merge remote-tracking branch 'origin/graphql-data-removal' into graph…
anmarhindi Jan 9, 2025
b5dbf6e
embedding, fix camel case, heuristic
LennartSchmidtKern Jan 9, 2025
4e94d99
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 9, 2025
26e7e44
labeling
LennartSchmidtKern Jan 9, 2025
7439b41
misc, look up
LennartSchmidtKern Jan 9, 2025
60cb4f6
rename get_custom_response function
anmarhindi Jan 9, 2025
d8e3628
Update delete-project and update-project-name-description
anmarhindi Jan 9, 2025
8043101
update-project-status & update-project-tokenizer silent response
anmarhindi Jan 9, 2025
2e1ee26
Fix: prepare-record-export
anmarhindi Jan 9, 2025
ae2a796
Fix: calculate_user_attribute_all_records & update_attribute
anmarhindi Jan 9, 2025
b01eec9
perf: eliminate get_embeddings_schema unused function
andhreljaKern Jan 9, 2025
8e58b68
Merge branch 'graphql-data-removal' of https://github.com/code-kern-a…
andhreljaKern Jan 9, 2025
949fea7
fix: prepare_project_export
anmarhindi Jan 9, 2025
ed99b48
proect settings
LennartSchmidtKern Jan 9, 2025
d8a01e9
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 9, 2025
488b0eb
fix: project-size, json cannot encode Decimal.
anmarhindi Jan 9, 2025
8a78e10
resolve conflict
anmarhindi Jan 9, 2025
f8603e4
remove duplicate import
anmarhindi Jan 9, 2025
df5e51f
model
LennartSchmidtKern Jan 9, 2025
96005f0
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 9, 2025
2b6def3
gen fail
LennartSchmidtKern Jan 9, 2025
4404c3d
remove unused import
anmarhindi Jan 9, 2025
254e81e
Merge remote-tracking branch 'origin/graphql-data-removal' into graph…
anmarhindi Jan 9, 2025
fb94074
ref
anmarhindi Jan 9, 2025
c52fe96
remove unused embedding
LennartSchmidtKern Jan 9, 2025
7036758
Merge branch 'graphql-data-removal' of github.com:code-kern-ai/refine…
LennartSchmidtKern Jan 9, 2025
843b82d
perf: move column whitelist to submodules
andhreljaKern Jan 9, 2025
715883c
Merge branch 'graphql-data-removal' of https://github.com/code-kern-a…
andhreljaKern Jan 9, 2025
ed6a3b4
model
LennartSchmidtKern Jan 10, 2025
c54ab1f
silent success
LennartSchmidtKern Jan 10, 2025
9991248
Handle exceptions with direct returns
anmarhindi Jan 13, 2025
3a7b7c4
Remove type hint
anmarhindi Jan 13, 2025
7de1b7f
Remove print
anmarhindi Jan 13, 2025
80f1f2e
perf: update submodules
andhreljaKern Jan 13, 2025
ebeb9b4
Merge branch 'graphql-data-removal' of https://github.com/code-kern-a…
andhreljaKern Jan 13, 2025
da77a83
Remove unused key
anmarhindi Jan 13, 2025
9f545a6
Add list comprehension all-projects-mini
anmarhindi Jan 13, 2025
49563cf
PR comments
LennartSchmidtKern Jan 13, 2025
b570c8a
PR embed
LennartSchmidtKern Jan 13, 2025
c132a3e
model
LennartSchmidtKern Jan 13, 2025
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
2 changes: 1 addition & 1 deletion controller/auth/kratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def resolve_user_mail_by_id(user_id: str) -> str:
return None


def resolve_user_name_by_id(user_id: str) -> str:
def resolve_user_name_by_id(user_id: str) -> Dict[str, str]:
i = __get_identity(user_id, False)
if i:
i = i["identity"]
Expand Down
99 changes: 0 additions & 99 deletions controller/embedding/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from submodules.model import enums
from submodules.model.models import Embedding
from util import notification
from . import util
from . import connector
from .terms import TERMS_INFO
from controller.model_provider import manager as model_manager
Expand All @@ -14,11 +13,8 @@
embedding,
agreement,
general,
project,
)
from submodules.model import daemon
from submodules.model.util import sql_alchemy_to_dict
from controller.embedding.connector import collection_on_qdrant


def get_terms_info(
Expand All @@ -29,19 +25,6 @@ def get_terms_info(
return list(TERMS_INFO.values())


def get_current_terms_text(
platform: str,
) -> Optional[str]:
terms = TERMS_INFO[platform]
term_text = terms.get("terms")
if not term_text:
return None
link = terms.get("link")
if link:
term_text = term_text.replace("@@PLACEHOLDER@@", link)
return term_text


def get_recommended_encoders() -> List[Any]:
# can run into circular import problems if directly resolved here by helper method
recommendations = connector.request_listing_recommended_encoders()
Expand Down Expand Up @@ -71,17 +54,6 @@ def get_recommended_encoders() -> List[Any]:
return recommendations


def create_embedding(project_id: str, embedding_id: str) -> None:
daemon.run_without_db_token(connector.request_embedding, project_id, embedding_id)


def create_embeddings_one_by_one(
project_id: str,
embeddings_ids: List[str],
) -> None:
daemon.run_without_db_token(__embed_one_by_one_helper, project_id, embeddings_ids)


def request_tensor_upload(project_id: str, embedding_id: str) -> Any:
connector.request_tensor_upload(project_id, embedding_id)

Expand All @@ -92,21 +64,6 @@ def delete_embedding(project_id: str, embedding_id: str) -> None:
connector.request_deleting_embedding(project_id, embedding_id)


def __embed_one_by_one_helper(project_id: str, embeddings_ids: List[str]) -> None:
ctx_token = general.get_ctx_token()
for embedding_id in embeddings_ids:
connector.request_embedding(project_id, embedding_id)
time.sleep(5)
c = 1
while util.has_encoder_running(project_id):
c += 1
if c > 12:
ctx_token = general.remove_and_refresh_session(ctx_token, True)
c = 1
time.sleep(5)
general.remove_and_refresh_session(ctx_token, False)


def get_embedding_name(
project_id: str,
attribute_id: str,
Expand Down Expand Up @@ -142,62 +99,6 @@ def get_embedding_name(
return name


EMBEDDING_SCHEMA_WHITELIST = [
"id",
"name",
"custom",
"type",
"state",
"progress",
"dimension",
"count",
"platform",
"model",
"filter_attributes",
"attribute_id",
]


def get_embedding_schema(project_id: str) -> List[Dict[str, Any]]:
embeddings = embedding.get_all_embeddings_by_project_id(project_id)
embedding_dict = sql_alchemy_to_dict(
embeddings, column_whitelist=EMBEDDING_SCHEMA_WHITELIST
)
number_records = len(project.get(project_id).records)
expanded_embeddings = []
for embed in embedding_dict:
count = embedding.get_tensor_count(embed["id"])
onQdrant = collection_on_qdrant(project_id, embed["id"])

embedding_item = embedding.get_tensor(embed["id"])
dimension = 0
if embedding_item is not None:
# distinguish between token and attribute embeddings
if type(embedding_item.data[0]) is list:
dimension = len(embedding_item.data[0])
else:
dimension = len(embedding_item.data)

if embed["state"] == "FINISHED":
progress = 1
elif embed["state"] == "INITIALIZING" or embed["state"] == "WAITING":
progress = 0.0
else:
progress = min(
0.1 + (count / number_records * 0.9),
0.99,
)
expanded_embed = {
**embed,
"progress": progress,
"count": count,
"dimension": dimension,
"onQdrant": onQdrant,
}
expanded_embeddings.append(expanded_embed)
return {"id": project_id, "embeddings": expanded_embeddings}


def recreate_embeddings(
project_id: str, embedding_ids: Optional[List[str]] = None, user_id: str = None
) -> None:
Expand Down
5 changes: 0 additions & 5 deletions controller/embedding/util.py

This file was deleted.

16 changes: 6 additions & 10 deletions fast_api/routes/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from controller.auth import manager as auth_manager
from typing import List, Union
from fast_api.models import DeleteUserAttributeBody
from fast_api.routes.client_response import pack_json_result
from fast_api.routes.client_response import pack_json_result, get_silent_success
from fastapi import APIRouter, Body, Depends, Query, Request
from submodules.model.enums import NotificationType
from submodules.model.util import sql_alchemy_to_dict
Expand Down Expand Up @@ -34,7 +34,7 @@ def get_attributes(
):
data = manager.get_all_attributes(project_id, state_filter)
data_dict = sql_alchemy_to_dict(data, column_whitelist=ALL_ATTRIBUTES_WHITELIST)
return pack_json_result({"data": {"attributesByProjectId": data_dict}})
return pack_json_result(data_dict)


@router.get(
Expand All @@ -54,7 +54,7 @@ def get_check_composite_key(
project_id,
)

return pack_json_result({"data": {"checkCompositeKey": is_valid}})
return pack_json_result(is_valid)


@router.get(
Expand All @@ -71,12 +71,8 @@ def get_sample_records(
)
return pack_json_result(
{
"data": {
"calculateUserAttributeSampleRecords": {
"record_ids": record_ids,
"calculated_attributes": calculated_attributes,
}
}
"record_ids": record_ids,
"calculated_attributes": calculated_attributes,
}
)

Expand All @@ -91,4 +87,4 @@ def delete_user_attribute(
body: DeleteUserAttributeBody = Body(...),
):
manager.delete_attribute(project_id, body.attribute_id)
return pack_json_result({"data": {"deleteUserAttribute": {"ok": True}}})
return get_silent_success()
13 changes: 13 additions & 0 deletions fast_api/routes/client_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,18 @@ def get_silent_success() -> JSONResponse:
return SILENT_SUCCESS_RESPONSE


def get_custom_response(status_code, content, type="text") -> PlainTextResponse:
if type == "json":
return JSONResponse(
status_code=status_code,
content=content,
)
else:
return PlainTextResponse(
status_code=status_code,
content=content,
)


def to_json(obj: BaseModel):
return json.loads(obj.json())
13 changes: 5 additions & 8 deletions fast_api/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
DeleteCommentBody,
UpdateCommentBody,
)
from fast_api.routes.client_response import pack_json_result
from fast_api.routes.client_response import pack_json_result, get_silent_success
from submodules.model.enums import CommentCategory
from util import notification
from middleware.log_storage import extend_state_get_like


router = APIRouter()


Expand Down Expand Up @@ -56,9 +55,7 @@ def get_all_comments(request: Request):
"add_info": add_info,
}

return pack_json_result(
{"data": {"getAllComments": to_return}}, wrap_for_frontend=False
)
return pack_json_result(to_return, wrap_for_frontend=False)


@router.post("/create-comment")
Expand All @@ -84,7 +81,7 @@ def create_comment(request: Request, body: CreateCommentBody = Body(...)):
True,
)

return pack_json_result({"data": {"createComment": {"ok": True}}})
return get_silent_success()


@router.delete("/delete-comment")
Expand All @@ -109,7 +106,7 @@ def delete_comment(
True,
)

return pack_json_result({"data": {"deleteComment": {"ok": True}}})
return get_silent_success()


@router.put("/update-comment")
Expand All @@ -134,7 +131,7 @@ def update_comment(
True,
)

return pack_json_result({"data": {"updateComment": {"ok": True}}})
return get_silent_success()


@router.get("/get-unique-comments-keys-for")
Expand Down
38 changes: 15 additions & 23 deletions fast_api/routes/data_browser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
from fastapi import APIRouter, Body, Depends, Request
from fastapi.responses import JSONResponse
from controller.auth import manager as auth_manager
from controller.record import manager as manager
from controller.data_slice import manager as data_slice_manager
Expand All @@ -14,7 +13,11 @@
SearchRecordsExtendedBody,
UpdateDataSliceBody,
)
from fast_api.routes.client_response import pack_json_result
from fast_api.routes.client_response import (
pack_json_result,
get_silent_success,
GENERIC_FAILURE_RESPONSE,
)
from service.search.search import resolve_extended_search
from submodules.model.business_objects import general
from util import notification
Expand Down Expand Up @@ -42,9 +45,7 @@ def get_record_comments(

user_id = auth_manager.get_user_id_by_info(request.state.info)
data = comment_manager.get_record_comments(project_id, user_id, record_ids)
return pack_json_result(
{"data": {"getRecordComments": data}}, wrap_for_frontend=False
)
return pack_json_result(data, wrap_for_frontend=False)


@router.post(
Expand Down Expand Up @@ -81,7 +82,7 @@ def search_records_extended(
"sessionId": results.session_id,
}

return pack_json_result({"data": {"searchRecordsExtended": data}})
return pack_json_result(data)


@router.post(
Expand Down Expand Up @@ -113,7 +114,7 @@ def search_records_extended_cog(
"recordList": record_list_pop,
}

return pack_json_result({"data": {"searchRecordsExtended": data}})
return pack_json_result(data)


@router.post(
Expand Down Expand Up @@ -142,10 +143,7 @@ def create_outlier_slice(
project_id, f"data_slice_created:{str(data_slice_item.id)}"
)

return JSONResponse(
status_code=201,
content={"message": "Outlier slice created"},
)
return get_silent_success()


@router.post(
Expand Down Expand Up @@ -183,7 +181,7 @@ def get_records_by_static_slice(
"sessionId": results.session_id,
}

return pack_json_result({"data": {"recordsByStaticSlice": data}})
return pack_json_result(data)


@router.post(
Expand All @@ -210,15 +208,10 @@ def create_data_slice(
project_id, f"data_slice_created:{str(data_slice_item.id)}"
)
data = {"id": str(data_slice_item.id), "__typename": "CreateDataSlice"}
return pack_json_result(
{"data": {"createDataSlice": data}}, wrap_for_frontend=False
)
return pack_json_result(data, wrap_for_frontend=False)
except Exception as e:
handle_error(e, user.id, project_id)
return JSONResponse(
status_code=400,
content={"message": str(e)},
)
return GENERIC_FAILURE_RESPONSE


@router.post(
Expand Down Expand Up @@ -256,7 +249,7 @@ def get_search_records_by_similarity(
"sessionId": results.session_id,
}

return pack_json_result({"data": {"searchRecordsBySimilarity": data}})
return pack_json_result(data)


@router.post(
Expand All @@ -270,7 +263,6 @@ def update_data_slice(
):

user = auth_manager.get_user_by_info(request.state.info)
ok = False

try:
raw = json.loads(dataSliceBody.filter_raw)
Expand All @@ -287,11 +279,11 @@ def update_data_slice(
notification.send_organization_update(
project_id, f"data_slice_updated:{dataSliceBody.data_slice_id}"
)
ok = True
except Exception as e:
handle_error(e, user.id, project_id)
return GENERIC_FAILURE_RESPONSE

return pack_json_result({"data": {"updateDataSlice": {"ok": ok}}})
return get_silent_success()


def handle_error(exception: Exception, user_id: str, project_id: str):
Expand Down
Loading