Skip to content
Open
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
8 changes: 2 additions & 6 deletions unstructured/staging/label_studio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from copy import deepcopy
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union

Expand Down Expand Up @@ -84,16 +83,13 @@ class LabelStudioAnnotation:
was_canceled: bool = False # Indicates whether or not the annotation was canceled

def to_dict(self):
annotation_dict = deepcopy(self.__dict__)
annotation_dict = dict(self.__dict__)
annotation_dict["result"] = [r.to_dict() for r in annotation_dict["result"]]
if "reviews" in annotation_dict and annotation_dict["reviews"] is not None:
annotation_dict["reviews"] = [r.to_dict() for r in annotation_dict["reviews"]]

# NOTE(robinson) - Removes keys for any fields that defaulted to None
_annotation_dict = deepcopy(annotation_dict)
for key, value in annotation_dict.items():
if value is None:
_annotation_dict.pop(key)
_annotation_dict = {k: v for k, v in annotation_dict.items() if v is not None}

return _annotation_dict

Expand Down