Skip to content

Commit f9065b6

Browse files
authored
feat: propagate data group hash through label row (#955)
1 parent 8e38420 commit f9065b6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

encord/objects/ontology_labels_impl.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ def data_hash(self) -> str:
152152
"""
153153
return self._label_row_read_only_data.data_hash
154154

155+
@property
156+
def group_hash(self) -> Optional[str]:
157+
"""Returns the group hash of the data row.
158+
159+
Only present if this label row is a child of a data group
160+
161+
Returns:
162+
Optional[str]: The data group hash.
163+
"""
164+
return self._label_row_read_only_data.group_hash
165+
155166
@property
156167
def dataset_hash(self) -> str:
157168
"""Returns the hash of the dataset.
@@ -1633,6 +1644,7 @@ class LabelRowReadOnlyData:
16331644
created_at: Optional[datetime]
16341645
last_edited_at: Optional[datetime]
16351646
data_hash: str
1647+
group_hash: Optional[str]
16361648
data_type: DataType
16371649
backing_item_uuid: Optional[UUID]
16381650
label_status: LabelStatus
@@ -2044,6 +2056,7 @@ def _parse_label_row_metadata(self, label_row_metadata: LabelRowMetadata) -> Lab
20442056
label_hash=label_row_metadata.label_hash,
20452057
branch_name=label_row_metadata.branch_name,
20462058
data_hash=label_row_metadata.data_hash,
2059+
group_hash=label_row_metadata.group_hash,
20472060
data_title=label_row_metadata.data_title,
20482061
dataset_hash=label_row_metadata.dataset_hash,
20492062
dataset_title=label_row_metadata.dataset_title,
@@ -2160,6 +2173,7 @@ def _parse_label_row_dict(self, label_row_dict: dict) -> LabelRowReadOnlyData:
21602173
dataset_title=label_row_dict["dataset_title"],
21612174
data_title=label_row_dict["data_title"],
21622175
data_hash=label_row_dict["data_hash"],
2176+
group_hash=label_row_dict.get("group_hash", self._label_row_read_only_data.group_hash),
21632177
data_type=data_type,
21642178
label_status=LabelStatus(label_row_dict["label_status"]),
21652179
annotation_task_status=label_row_dict.get("annotation_task_status"),

encord/orm/label_row.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class LabelRowMetadata(Formatter):
249249
"""Only present if the label row is initiated or branch_name is set specifically"""
250250

251251
data_hash: str
252+
"""Only present if the label row is for a child element of a group"""
252253
dataset_hash: str
253254
dataset_title: str
254255
data_title: str
@@ -277,6 +278,8 @@ class LabelRowMetadata(Formatter):
277278
audio_bit_depth: Optional[int]
278279
audio_num_channels: Optional[int]
279280

281+
group_hash: Optional[str] = None
282+
280283
task_uuid: Optional[UUID] = None
281284
priority: Optional[float] = None
282285
"""Only available for not complete tasks"""
@@ -309,6 +312,7 @@ def from_dict(cls, json_dict: Dict) -> LabelRowMetadata:
309312
created_at=created_at,
310313
last_edited_at=last_edited_at,
311314
data_hash=json_dict["data_hash"],
315+
group_hash=json_dict.get("group_hash", None),
312316
dataset_hash=json_dict["dataset_hash"],
313317
dataset_title=json_dict["dataset_title"],
314318
data_title=json_dict["data_title"],
@@ -389,6 +393,7 @@ class LabelRowMetadataDTO(BaseDTO):
389393
"""Only present if the label row is initiated or branch_name is set specifically"""
390394

391395
data_hash: str = Field(alias="data_uuid")
396+
group_hash: Optional[str] = Field(default=None, alias="group_uuid")
392397
dataset_hash: str = Field(alias="dataset_uuid")
393398
dataset_title: str
394399
data_title: str
@@ -438,6 +443,7 @@ def label_row_metadata_dto_to_label_row_metadata(label_row_metadata_dto: LabelRo
438443
created_at=label_row_metadata_dto.created_at,
439444
last_edited_at=label_row_metadata_dto.last_edited_at,
440445
data_hash=label_row_metadata_dto.data_hash,
446+
group_hash=label_row_metadata_dto.group_hash,
441447
dataset_hash=label_row_metadata_dto.dataset_hash,
442448
dataset_title=label_row_metadata_dto.dataset_title,
443449
data_title=label_row_metadata_dto.data_title,

0 commit comments

Comments
 (0)