diff --git a/controller/stats.py b/controller/stats.py index 99be797..275444d 100644 --- a/controller/stats.py +++ b/controller/stats.py @@ -11,6 +11,7 @@ labeling_task, notification, project, + user, ) import weak_nlp @@ -50,35 +51,44 @@ def send_organization_update( def send_warning_no_reference_data(project_id: str, user_id: str): - notification.create( - project_id, - user_id, - "You have no labeled data. Can't compute true positive-related statistics.", - "WARNING", - enums.NotificationType.MISSING_REFERENCE_DATA.value, - with_commit=True, - ) - organization_id = get_organization_id(project_id, user_id) - if organization_id: - send_organization_update( - project_id, f"notification_created:{user_id}", True, organization_id + if check_user_can_receive_notifications(user_id): + notification.create( + project_id, + user_id, + "You have no labeled data. Can't compute true positive-related statistics.", + "WARNING", + enums.NotificationType.MISSING_REFERENCE_DATA.value, + with_commit=True, ) + organization_id = get_organization_id(project_id, user_id) + if organization_id: + send_organization_update( + project_id, f"notification_created:{user_id}", True, organization_id + ) def send_warning_no_coverage_data(project_id: str, user_id: str): - notification.create( - project_id, - user_id, - "Your heuristics hits no records in the project. Can't compute statistics.", - "WARNING", - enums.NotificationType.MISSING_REFERENCE_DATA.value, - with_commit=True, - ) - organization_id = get_organization_id(project_id, user_id) - if organization_id: - send_organization_update( - project_id, f"notification_created:{user_id}", True, organization_id + if check_user_can_receive_notifications(user_id): + notification.create( + project_id, + user_id, + "Your heuristics hits no records in the project. Can't compute statistics.", + "WARNING", + enums.NotificationType.MISSING_REFERENCE_DATA.value, + with_commit=True, ) + organization_id = get_organization_id(project_id, user_id) + if organization_id: + send_organization_update( + project_id, f"notification_created:{user_id}", True, organization_id + ) + + +def check_user_can_receive_notifications(user_id: str) -> bool: + user_item = user.get(user_id) + if user_item.role == enums.UserRoles.ENGINEER.value: + return True + return False def calculate_quality_statistics_for_labeling_task( @@ -214,6 +224,7 @@ def classification_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, in def extraction_quality(df: pd.DataFrame) -> Dict[str, Dict[str, Dict[str, int]]]: + enlm = util.get_enlm_from_df(df) quality_df = enlm.quality_metrics() stats = {} diff --git a/dev.Dockerfile b/dev.Dockerfile index c47097c..7794cb1 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -10,4 +10,7 @@ RUN pip3 install -r requirements.txt COPY / . +# to run with local version of weak-nlp, clone the weak-nlp repo inside and uncomment +# RUN pip3 install -e weak-nlp + CMD [ "/usr/local/bin/uvicorn", "--host", "0.0.0.0", "--port", "80", "app:app", "--reload" ] diff --git a/requirements.txt b/requirements.txt index f8029a1..024eee0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,4 +35,4 @@ tomli==1.2.2 typing-extensions==3.10.0.2 uvicorn==0.15.0 zipp==3.7.0 -weak-nlp==0.0.10 +weak-nlp==0.0.11 diff --git a/submodules/model b/submodules/model index 2811dba..de478fc 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 2811dbacdc57359e803dffc4a88065ff06432a0a +Subproject commit de478fcbdb1ae937eae252add39475f61ffcdd68