Skip to content

Commit 82da08e

Browse files
authored
release updates for 1.3.4 (#61)
* Changes the activity log caller function logic to collect data before the thread * Adds unkown user creation logic for comments * Changes websocket notification positioning for project deletion * Fixes run on 10 issue * Adds missing source_code import to file import * Changes missing columns to query * PR comments * submodule change * Submodule change * Submodule change
1 parent a24502a commit 82da08e

File tree

7 files changed

+47
-58
lines changed

7 files changed

+47
-58
lines changed

controller/attribute/util.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,12 @@ def add_log_to_attribute_logs(
5050

5151
def prepare_sample_records_doc_bin(attribute_id: str, project_id: str) -> str:
5252

53-
sample_record_ids = [
54-
record_item
55-
for record_item, in record.get_attribute_calculation_sample_records(project_id)
56-
]
57-
58-
missing_columns = [
59-
attribute_item.name
60-
for attribute_item in attribute.get_all(project_id)
61-
if attribute_item.data_type != DataTypes.TEXT.value
62-
]
63-
missing_columns_str = ",\n".join(
64-
["'" + k + "',r.data->'" + k + "'" for k in missing_columns]
65-
)
53+
sample_records = record.get_attribute_calculation_sample_records(project_id)
6654

6755
sample_records_doc_bin = tokenization.get_doc_bin_table_to_json(
6856
project_id=project_id,
69-
missing_columns=missing_columns_str,
70-
record_ids=sample_record_ids,
57+
missing_columns=record.get_missing_columns_str(project_id),
58+
record_ids=[r[0] for r in sample_records],
7159
)
7260
project_item = project.get(project_id)
7361
org_id = str(project_item.organization_id)

controller/payload/payload_scheduler.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def prepare_sample_records_doc_bin(
707707

708708
sample_records_doc_bin = get_doc_bin_table_to_json(
709709
project_id=project_id,
710-
missing_columns=get_missing_columns_tokenization(project_id),
710+
missing_columns=record.get_missing_columns_str(project_id),
711711
record_ids=[r[0] for r in sample_records],
712712
)
713713
project_item = project.get(project_id)
@@ -790,16 +790,3 @@ def run_labeling_function_exec_env(
790790
s3.delete_object(org_id, project_id + "/" + prefixed_knowledge_base)
791791

792792
return calculated_labels, container_logs, code_has_errors
793-
794-
795-
def get_missing_columns_tokenization(project_id: str) -> str:
796-
missing_columns = [
797-
attribute_item.name
798-
for attribute_item in attribute.get_all(project_id)
799-
if attribute_item.data_type != enums.DataTypes.TEXT.value
800-
]
801-
missing_columns_str = ",\n".join(
802-
["'" + k + "',r.data->'" + k + "'" for k in missing_columns]
803-
)
804-
805-
return missing_columns_str

controller/transfer/project_transfer_manager.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ def import_file(
205205
logs=attribute_item.get(
206206
"logs",
207207
),
208+
source_code=attribute_item.get(
209+
"source_code",
210+
),
208211
project_id=project_id,
209212
)
210213
attribute_ids_by_old_id[
@@ -399,6 +402,12 @@ def import_file(
399402
if created_by not in used_user_ids:
400403
used_user_ids.append(created_by)
401404

405+
if "comments" in data:
406+
for comment_item in data.get("comments"):
407+
created_by = comment_item.get("created_by")
408+
if created_by not in used_user_ids:
409+
used_user_ids.append(created_by)
410+
402411
if used_user_ids:
403412
existing_users = user.get_by_id_list(used_user_ids)
404413
existing_users = [str(u.id) for u in existing_users]
@@ -787,19 +796,19 @@ def import_file(
787796
xftype = comment_item.get("xftype")
788797
if xftype == enums.CommentCategory.RECORD.value:
789798
new_xfkey = record_ids.get(old_xfkey)
790-
if xftype == enums.CommentCategory.LABELING_TASK.value:
799+
elif xftype == enums.CommentCategory.LABELING_TASK.value:
791800
new_xfkey = labeling_task_ids.get(old_xfkey)
792-
if xftype == enums.CommentCategory.ATTRIBUTE.value:
801+
elif xftype == enums.CommentCategory.ATTRIBUTE.value:
793802
new_xfkey = attribute_ids_by_old_id.get(old_xfkey)
794-
if xftype == enums.CommentCategory.LABEL.value:
803+
elif xftype == enums.CommentCategory.LABEL.value:
795804
new_xfkey = labeling_task_labels_ids.get(old_xfkey)
796-
if xftype == enums.CommentCategory.DATA_SLICE.value:
805+
elif xftype == enums.CommentCategory.DATA_SLICE.value:
797806
new_xfkey = data_slice_ids.get(old_xfkey)
798-
if xftype == enums.CommentCategory.EMBEDDING.value:
807+
elif xftype == enums.CommentCategory.EMBEDDING.value:
799808
new_xfkey = embedding_ids.get(old_xfkey)
800-
if xftype == enums.CommentCategory.HEURISTIC.value:
809+
elif xftype == enums.CommentCategory.HEURISTIC.value:
801810
new_xfkey = information_source_ids.get(old_xfkey)
802-
if xftype == enums.CommentCategory.KNOWLEDGE_BASE.value:
811+
elif xftype == enums.CommentCategory.KNOWLEDGE_BASE.value:
803812
new_xfkey = knowledge_base_ids.get(old_xfkey)
804813
if not new_xfkey:
805814
continue
@@ -808,7 +817,7 @@ def import_file(
808817
xfkey=new_xfkey,
809818
xftype=comment_item.get("xftype"),
810819
comment=comment_item.get("comment"),
811-
created_by=import_user_id,
820+
created_by=comment_item.get("created_by"),
812821
project_id=project_id,
813822
order_key=comment_item.get("order_key"),
814823
is_markdown=comment_item.get("is_markdown"),

graphql_api/mutation/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def mutate(self, info, project_id: str):
7373
notification.create_notification(
7474
enums.NotificationType.PROJECT_DELETED, user.id, None, project_item.name
7575
)
76+
manager.delete_project(project_id)
7677
notification.send_organization_update(
7778
project_id, f"project_deleted:{project_id}", True, organization_id
7879
)
79-
manager.delete_project(project_id)
8080
return DeleteProject(ok=True)
8181

8282

submodules/model

util/doc_ock.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import inspect
12
import os
23
import traceback
4+
from typing import Dict, Union
35
from controller.misc import config_service
46
from submodules.model import models, events
57
from util import daemon, service_requests
@@ -22,15 +24,31 @@ def register_user(user: models.User):
2224

2325

2426
def post_event(user: models.User, event: events.Event):
25-
daemon.run(__post_thread, user, event)
27+
caller_dict = __get_caller_data()
28+
daemon.run(__post_thread, user, event, caller_dict)
2629

27-
def __post_thread(user: models.User, event: events.Event):
30+
31+
def __post_thread(
32+
user: models.User, event: events.Event, caller_dict: Dict[str, Union[str, int]]
33+
):
2834
try:
2935
url = f"{BASE_URI}/track/{user.id}/{event.event_name()}"
3036
event.IsManaged = config_service.get_config_value("is_managed")
3137
add_user_activity_entry(
32-
str(user.id), {"eventName": event.event_name(), **event.__dict__}
38+
str(user.id),
39+
{"eventName": event.event_name(), **event.__dict__},
40+
caller_dict,
3341
)
3442
service_requests.post_call_or_raise(url, event.__dict__)
3543
except Exception:
3644
print(traceback.format_exc(), flush=True)
45+
46+
47+
def __get_caller_data() -> Dict[str, Union[str, int]]:
48+
parent = inspect.stack()[2]
49+
# not this function (index 0), not the parent (post_event - index 1) but the one before (index 2)
50+
return {
51+
"caller_function": parent.function,
52+
"caller_file": parent.filename,
53+
"caller_lineno": parent.lineno,
54+
}

util/user_activity.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,15 @@
55
from util import daemon
66
import os
77
from datetime import datetime
8-
import inspect
98
import json
109

1110
BACKUP_FILE_PATH = "user_activity_backup.tmp"
1211
__thread_running = False
1312

1413

15-
def get_caller_data() -> Dict[str, Union[str, int]]:
16-
# not this, not the parent (add_user_actvity) but the one before
17-
parent = inspect.stack()[2]
18-
if parent.function == "post_event" and parent.filename == "./util/doc_ock.py":
19-
# one step higher
20-
parent = inspect.stack()[3]
21-
return {
22-
"caller_function": parent.function,
23-
"caller_file": parent.filename,
24-
"caller_lineno": parent.lineno,
25-
}
26-
27-
28-
def add_user_activity_entry(user_id: str, activity: Any) -> None:
29-
caller_dict = get_caller_data()
14+
def add_user_activity_entry(
15+
user_id: str, activity: Any, caller_dict: Dict[str, Union[str, int]]
16+
) -> None:
3017
if isinstance(activity, str):
3118
activity = {**caller_dict, "activity": activity}
3219
else:

0 commit comments

Comments
 (0)