Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions controller/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
labeling_task,
notification,
project,
user,
)
import weak_nlp

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 = {}
Expand Down
3 changes: 3 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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