Skip to content

Commit 010d260

Browse files
release updates (#7)
* Only send notifications for engineers * added todo for checking errors in weak nlp * updates submodule Co-authored-by: felix0496 <felix.kirsch@kern.ai>
1 parent 9d09182 commit 010d260

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

controller/stats.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
labeling_task,
1212
notification,
1313
project,
14+
user,
1415
)
1516
import weak_nlp
1617

@@ -50,35 +51,44 @@ def send_organization_update(
5051

5152

5253
def send_warning_no_reference_data(project_id: str, user_id: str):
53-
notification.create(
54-
project_id,
55-
user_id,
56-
"You have no labeled data. Can't compute true positive-related statistics.",
57-
"WARNING",
58-
enums.NotificationType.MISSING_REFERENCE_DATA.value,
59-
with_commit=True,
60-
)
61-
organization_id = get_organization_id(project_id, user_id)
62-
if organization_id:
63-
send_organization_update(
64-
project_id, f"notification_created:{user_id}", True, organization_id
54+
if check_user_can_receive_notifications(user_id):
55+
notification.create(
56+
project_id,
57+
user_id,
58+
"You have no labeled data. Can't compute true positive-related statistics.",
59+
"WARNING",
60+
enums.NotificationType.MISSING_REFERENCE_DATA.value,
61+
with_commit=True,
6562
)
63+
organization_id = get_organization_id(project_id, user_id)
64+
if organization_id:
65+
send_organization_update(
66+
project_id, f"notification_created:{user_id}", True, organization_id
67+
)
6668

6769

6870
def send_warning_no_coverage_data(project_id: str, user_id: str):
69-
notification.create(
70-
project_id,
71-
user_id,
72-
"Your heuristics hits no records in the project. Can't compute statistics.",
73-
"WARNING",
74-
enums.NotificationType.MISSING_REFERENCE_DATA.value,
75-
with_commit=True,
76-
)
77-
organization_id = get_organization_id(project_id, user_id)
78-
if organization_id:
79-
send_organization_update(
80-
project_id, f"notification_created:{user_id}", True, organization_id
71+
if check_user_can_receive_notifications(user_id):
72+
notification.create(
73+
project_id,
74+
user_id,
75+
"Your heuristics hits no records in the project. Can't compute statistics.",
76+
"WARNING",
77+
enums.NotificationType.MISSING_REFERENCE_DATA.value,
78+
with_commit=True,
8179
)
80+
organization_id = get_organization_id(project_id, user_id)
81+
if organization_id:
82+
send_organization_update(
83+
project_id, f"notification_created:{user_id}", True, organization_id
84+
)
85+
86+
87+
def check_user_can_receive_notifications(user_id: str) -> bool:
88+
user_item = user.get(user_id)
89+
if user_item.role == enums.UserRoles.ENGINEER.value:
90+
return True
91+
return False
8292

8393

8494
def calculate_quality_statistics_for_labeling_task(
@@ -214,8 +224,12 @@ def classification_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, in
214224

215225

216226
def extraction_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, int]]]:
227+
# print(df, flush=True)
228+
217229
enlm = util.get_enlm_from_df(df)
218230
quality_df = enlm.quality_metrics()
231+
print(quality_df, flush=True)
232+
print(enlm.errors, flush=True)
219233
stats = {}
220234
if len(quality_df) > 0:
221235
for source_id, quality_df_sub_source in quality_df.groupby("identifier"):

dev.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ RUN pip3 install -r requirements.txt
1010

1111
COPY / .
1212

13+
# to run with local version of weak-nlp, clone the weak-nlp repo inside and uncomment
14+
# RUN pip3 install -e weak-nlp
15+
1316
CMD [ "/usr/local/bin/uvicorn", "--host", "0.0.0.0", "--port", "80", "app:app", "--reload" ]

0 commit comments

Comments
 (0)