Skip to content

Commit 3d4cb8d

Browse files
author
Val Brodsky
committed
Allow to process legacy conversation data without row_data
1 parent 3f25c4c commit 3d4cb8d

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

libs/labelbox/src/labelbox/schema/internal/data_row_uploader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def upload_in_chunks(client, specs: List[DataRowItemBase],
2020
file_upload_thread_count: int,
2121
max_chunk_size_bytes: int) -> UploadManifest:
2222
empty_specs = list(filter(lambda spec: spec.is_empty(), specs))
23-
2423
if empty_specs:
2524
ids = list(map(lambda spec: spec.id.get("value"), empty_specs))
2625
ids = list(filter(lambda x: x is not None and len(x) > 0, ids))

libs/labelbox/src/labelbox/schema/internal/data_row_upsert_item.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ def is_empty(self) -> bool:
8181
"""
8282
row_data = self.payload.get("row_data", None) or self.payload.get(
8383
DataRow.row_data, None)
84-
return (not self.payload or len(self.payload.keys()) == 1 and
85-
"dataset_id" in self.payload or row_data is None or
86-
len(row_data) == 0)
84+
85+
return (not self._is_legacy_conversational_data() and
86+
(not self.payload or len(self.payload.keys()) == 1 and
87+
"dataset_id" in self.payload or row_data is None or
88+
len(row_data) == 0))
89+
90+
def _is_legacy_conversational_data(self) -> bool:
91+
return "conversationalData" in self.payload.keys(
92+
) or "conversational_data" in self.payload.keys()
8793

8894
@classmethod
8995
def build(

libs/labelbox/tests/unit/test_data_row_upsert_data.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,25 @@ def test_create_is_empty():
125125
payload={DataRow.row_data: "http://my_site.com/photos/img_01.jpg"})
126126
assert not item.is_empty()
127127

128+
legacy_converstational_data_payload = {
129+
"externalId":
130+
"Convo-123",
131+
"type":
132+
"application/vnd.labelbox.conversational",
133+
"conversationalData": [{
134+
"messageId":
135+
"message-0",
136+
"content":
137+
"I love iphone! i just bought new iphone! :smiling_face_with_3_hearts: :calling:",
138+
"user": {
139+
"userId": "Bot 002",
140+
"name": "Bot"
141+
},
142+
}]
143+
}
144+
item = DataRowCreateItem(id={}, payload=legacy_converstational_data_payload)
145+
assert not item.is_empty()
146+
128147

129148
def test_create_row_data_none():
130149
items = [

0 commit comments

Comments
 (0)