Skip to content

Commit 9eb2f07

Browse files
authored
Release v1.3.0 (#8)
1 parent e0ecf67 commit 9eb2f07

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

controller/stats.py

Lines changed: 35 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,6 +224,7 @@ 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+
217228
enlm = util.get_enlm_from_df(df)
218229
quality_df = enlm.quality_metrics()
219230
stats = {}

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" ]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ tomli==1.2.2
3535
typing-extensions==3.10.0.2
3636
uvicorn==0.15.0
3737
zipp==3.7.0
38-
weak-nlp==0.0.10
38+
weak-nlp==0.0.11

0 commit comments

Comments
 (0)