Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for inter-annotator-difference #144

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.9.20
- name: Set up Python 3.9.21
uses: actions/setup-python@v1
with:
python-version: 3.9.20
python-version: 3.9.21
- name: Debug Message - Check Github branch
run: echo "Current Git branch is ${GITHUB_REF##*/}"
- name: Install Black
Expand Down
6 changes: 3 additions & 3 deletions backend/dataset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ def download(self, request, pk):
json_data = json.dumps(exported_items, default=str)
# Create a StreamingHttpResponse with the JSON data
response = StreamingHttpResponse(json_data, content_type="application/json")
response[
"Content-Disposition"
] = f'attachment; filename="{dataset_instance}.json"'
response["Content-Disposition"] = (
f'attachment; filename="{dataset_instance}.json"'
)
return response
return StreamingHttpResponse(
exported_items, status=status.HTTP_200_OK, content_type=content_type
Expand Down
24 changes: 12 additions & 12 deletions backend/functions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,25 +452,25 @@ def get_modified_stats_result(
for key, value in result_rev_anno_stats.items():
result[f"Reviewer - {key.replace('_', ' ').title()} Annotations"] = value
for key, value in result_sup_anno_stats.items():
result[
f"Superchecker - {key.replace('_', ' ').title()} Annotations"
] = value
result[f"Superchecker - {key.replace('_', ' ').title()} Annotations"] = (
value
)
if meta_stats or complete_stats:
for key, value in result_ann_meta_stats.items():
for sub_key in value.keys():
result[
f"Annotator - {key.replace('_', ' ').title()} {sub_key}"
] = value[sub_key]
result[f"Annotator - {key.replace('_', ' ').title()} {sub_key}"] = (
value[sub_key]
)
for key, value in result_rev_meta_stats.items():
for sub_key in value.keys():
result[f"Reviewer - {key.replace('_', ' ').title()} {sub_key}"] = value[
sub_key
]
for key, value in result_sup_meta_stats.items():
for sub_key in value.keys():
result[
f"Superchecker - {key.replace('_', ' ').title()} {sub_key}"
] = value[sub_key]
result[f"Superchecker - {key.replace('_', ' ').title()} {sub_key}"] = (
value[sub_key]
)

# adding unassigned tasks count
result["Annotator - Unassigned Tasks"] = get_task_count_unassigned(proj_id, user)
Expand Down Expand Up @@ -770,9 +770,9 @@ def schedule_mail_to_download_all_projects(
query_params = QueryDict(mutable=True)
query_params["include_input_data_metadata_json"] = "true"
query_params["export_type"] = "CSV"
query_params[
"task_status"
] = "incomplete,annotated,reviewed,super_checked,exported"
query_params["task_status"] = (
"incomplete,annotated,reviewed,super_checked,exported"
)
custom_request = Request(factory.get(url, data=query_params, timeout=15))
custom_request.user = user
try:
Expand Down
4 changes: 1 addition & 3 deletions backend/notifications/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def create_notification_handler(
else (
f"/projects/{project_id}"
if project_id
else f"/task/{task_id}"
if task_id
else None
else f"/task/{task_id}" if task_id else None
)
)
new_notif = Notification(
Expand Down
20 changes: 5 additions & 15 deletions backend/organizations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def get_all_annotation_reports(
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
role = get_role_name(user.role)
Expand Down Expand Up @@ -130,9 +128,7 @@ def get_all_review_reports(
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
role = get_role_name(user.role)
Expand Down Expand Up @@ -246,9 +242,7 @@ def get_all_supercheck_reports(
else (
"Part Time"
if user.participation_type == 2
else "Contract Basis"
if user.participation_type == 4
else "N/A"
else "Contract Basis" if user.participation_type == 4 else "N/A"
)
)
role = get_role_name(user.role)
Expand Down Expand Up @@ -464,9 +458,7 @@ def send_user_reports_mail_org(
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
for participation_type in participation_types
Expand Down Expand Up @@ -1199,9 +1191,7 @@ def send_user_analytics_mail_org(
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
role = get_role_name(annotator.role)
Expand Down
14 changes: 5 additions & 9 deletions backend/organizations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,7 @@ def quality_reports(self, request, pk=None):
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
role = get_role_name(annotator.role)
Expand Down Expand Up @@ -776,9 +774,7 @@ def user_analytics(self, request, pk=None):
else (
"Part Time"
if participation_type == 2
else "Contract Basis"
if participation_type == 4
else "N/A"
else "Contract Basis" if participation_type == 4 else "N/A"
)
)
role = get_role_name(annotator.role)
Expand Down Expand Up @@ -902,9 +898,9 @@ def iter_items(items, pseudo_buffer):
status=status.HTTP_200_OK,
content_type="text/csv",
)
response[
"Content-Disposition"
] = f'attachment; filename="{organization.title}_user_analytics.csv"'
response["Content-Disposition"] = (
f'attachment; filename="{organization.title}_user_analytics.csv"'
)
return response

return Response(data=final_result, status=status.HTTP_200_OK)
Expand Down
8 changes: 6 additions & 2 deletions backend/projects/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def add_extra_task_data(t, project):
.filter(review_user__isnull=True)
)
total_ratings, seen = [], {}
max_rating, curr_response = float("-inf"), ""
max_rating, curr_response, min_rating = float("-inf"), "", float("inf")
for st in similar_tasks:
ann = Annotation.objects.filter(task=st, annotation_status=LABELED)[0]
for r in ann.result:
Expand Down Expand Up @@ -558,14 +558,18 @@ def add_extra_task_data(t, project):
seen[st.id] = curr_response
total_ratings.append(curr_response)
max_rating = max(max_rating, curr_response)
min_rating = min(min_rating, curr_response)
t.data["avg_rating"] = -1
t.data["curr_rating"] = -1
t.data["inter_annotator_difference"] = -1
if t.id in seen:
t.data["avg_rating"] = sum(total_ratings) / len(total_ratings)
t.data["total_rating"] = sum(total_ratings)
t.data["curr_rating"] = seen[t.id]
t.data["inter_annotator_difference"] = (
max_rating - seen[t.id] if max_rating > float("-inf") else -1
max_rating - min_rating
if (max_rating > float("-inf") and min_rating < float("inf"))
else -1
)
t.save()

Expand Down
16 changes: 8 additions & 8 deletions backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ def get_supercheck_reports(proj_id, userid, start_date, end_date):
result["Rejected Word Count"] = rejected_word_count
elif proj_type in get_audio_project_types():
result["Validated Segments Duration"] = validated_audio_duration
result[
"Validated With Changes Segments Duration"
] = validated_with_changes_audio_duration
result["Validated With Changes Segments Duration"] = (
validated_with_changes_audio_duration
)
result["Rejected Segments Duration"] = rejected_audio_duration
result["Total Raw Audio Duration"] = total_raw_audio_duration
result["Average Word Error Rate R/S"] = round(avg_word_error_rate, 2)
Expand Down Expand Up @@ -3790,11 +3790,11 @@ def download(self, request, pk=None, *args, **kwargs):
if include_input_data_metadata_json:
dataset_type = project.dataset_id.all()[0].dataset_type
dataset_model = getattr(dataset_models, dataset_type)
task_dict["data"][
"input_data_metadata_json"
] = dataset_model.objects.get(
pk=task_dict["input_data"]
).metadata_json
task_dict["data"]["input_data_metadata_json"] = (
dataset_model.objects.get(
pk=task_dict["input_data"]
).metadata_json
)
del task_dict["annotation_users"]
del task_dict["review_user"]
tasks_list.append(OrderedDict(task_dict))
Expand Down
80 changes: 43 additions & 37 deletions backend/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,12 +1215,16 @@ def get_users_recent_tasks(self, request):
"Project ID": annotation.task.project_id.id,
"Task ID": annotation.task.id,
"Updated at": utc_to_ist(annotation.updated_at),
"Annotated at": utc_to_ist(annotation.annotated_at)
if annotation.annotated_at
else None,
"Created at": utc_to_ist(annotation.created_at)
if annotation.created_at
else None,
"Annotated at": (
utc_to_ist(annotation.annotated_at)
if annotation.annotated_at
else None
),
"Created at": (
utc_to_ist(annotation.created_at)
if annotation.created_at
else None
),
}

response.append(data)
Expand Down Expand Up @@ -1656,16 +1660,16 @@ def partial_update(self, request, pk=None):
and len(annotation_obj.result) > len(request.data["result"])
):
request.data["result"] = annotation_obj.result
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
)
)
else:
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
)
)
annotation_response = super().partial_update(request)
if is_IDC:
Expand Down Expand Up @@ -1844,16 +1848,16 @@ def partial_update(self, request, pk=None):
and len(annotation_obj.result) > len(request.data["result"])
):
request.data["result"] = annotation_obj.result
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
)
)
else:
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
)
)
annotation_response = super().partial_update(request)
if is_IDC:
Expand Down Expand Up @@ -2053,16 +2057,16 @@ def partial_update(self, request, pk=None):
and len(annotation_obj.result) > len(request.data["result"])
):
request.data["result"] = annotation_obj.result
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
annotation_obj.result
)
)
else:
request.data[
"meta_stats"
] = compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
request.data["meta_stats"] = (
compute_meta_stats_for_instruction_driven_chat(
request.data["result"]
)
)
annotation_response = super().partial_update(request)
if is_IDC:
Expand Down Expand Up @@ -2197,9 +2201,11 @@ def convert_chitralekha_format_to_LSF(
text_dict = {
"origin": "manual",
"to_name": "audio_url",
"from_name": "transcribed_json"
if not is_acoustic
else "verbatim_transcribed_json",
"from_name": (
"transcribed_json"
if not is_acoustic
else "verbatim_transcribed_json"
),
"original_length": audio_duration,
}

Expand Down Expand Up @@ -2479,19 +2485,19 @@ def get_celery_tasks(request):
for i in filtered_tasks:
if filtered_tasks[i]["succeeded"] is not None:
filtered_tasks[i]["succeeded"] = datetime.fromtimestamp(
filtered_tasks[i]["succeeded"],tz=timezone.utc
filtered_tasks[i]["succeeded"], tz=timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if filtered_tasks[i]["failed"] is not None:
filtered_tasks[i]["failed"] = datetime.fromtimestamp(
filtered_tasks[i]["failed"],tz=timezone.utc
filtered_tasks[i]["failed"], tz=timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if filtered_tasks[i]["started"] is not None:
filtered_tasks[i]["started"] = datetime.fromtimestamp(
filtered_tasks[i]["started"],tz=timezone.utc
filtered_tasks[i]["started"], tz=timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if filtered_tasks[i]["received"] is not None:
filtered_tasks[i]["received"] = datetime.fromtimestamp(
filtered_tasks[i]["received"],tz=timezone.utc
filtered_tasks[i]["received"], tz=timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S.%fZ")

if "error" in filtered_tasks:
Expand Down
Loading
Loading