|
11 | 11 | labeling_task, |
12 | 12 | notification, |
13 | 13 | project, |
| 14 | + user, |
14 | 15 | ) |
15 | 16 | import weak_nlp |
16 | 17 |
|
@@ -50,35 +51,44 @@ def send_organization_update( |
50 | 51 |
|
51 | 52 |
|
52 | 53 | 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, |
65 | 62 | ) |
| 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 | + ) |
66 | 68 |
|
67 | 69 |
|
68 | 70 | 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, |
81 | 79 | ) |
| 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 |
82 | 92 |
|
83 | 93 |
|
84 | 94 | def calculate_quality_statistics_for_labeling_task( |
@@ -214,8 +224,12 @@ def classification_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, in |
214 | 224 |
|
215 | 225 |
|
216 | 226 | def extraction_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, int]]]: |
| 227 | + # print(df, flush=True) |
| 228 | + |
217 | 229 | enlm = util.get_enlm_from_df(df) |
218 | 230 | quality_df = enlm.quality_metrics() |
| 231 | + print(quality_df, flush=True) |
| 232 | + print(enlm.errors, flush=True) |
219 | 233 | stats = {} |
220 | 234 | if len(quality_df) > 0: |
221 | 235 | for source_id, quality_df_sub_source in quality_df.groupby("identifier"): |
|
0 commit comments