Skip to content

Commit 8e35a26

Browse files
author
Matt Sokoloff
committed
fix tests
1 parent 8dc2466 commit 8e35a26

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

labelbox/schema/data_row.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ class DataRow(DbObject, Updateable, BulkDeletable):
6161
supported_meta_types = supported_attachment_types = set(
6262
Entity.AssetAttachment.AttachmentType.__members__)
6363

64-
def __init__(self, client, field_values, **kwargs):
65-
field_values.update({'mediaType': MediaType.Unknown})
66-
super().__init__(client, field_values, **kwargs)
64+
def __init__(self, *args, **kwargs):
65+
super().__init__(*args, **kwargs)
6766
self.attachments.supports_filtering = False
6867
self.attachments.supports_sorting = False
6968

69+
def _set_field_values(self, field_values):
70+
field_values.update({'mediaType': MediaType.Unknown})
71+
super()._set_field_values(field_values)
72+
7073
@staticmethod
7174
def bulk_delete(data_rows) -> None:
7275
""" Deletes all the given DataRows.

labelbox/schema/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ def validate_keys(item):
353353

354354
def formatLegacyConversationalData(item):
355355
messages = item.pop("conversationalData")
356-
version = item.pop("version")
357-
type = item.pop("type")
356+
version = item.pop("version", 1)
357+
type = item.pop("type", "application/vnd.labelbox.conversational")
358358
if "externalId" in item:
359359
external_id = item.pop("externalId")
360360
item["external_id"] = external_id

labelbox/test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def run(fn, model_run):
2+
try:
3+
fn()
4+
except Exception as e:
5+
model_run.update_status(error_message=error)
6+
pipelines[pipeline].update_status(PipelineState.FAILED,
7+
json_data['model_run_id'],
8+
error_message=str(e))
9+
else:
10+
status
11+
12+
13+
def model_run(payload):
14+
15+
def etl():
16+
payload
17+
18+
run(etl)

tests/integration/test_data_row_media_attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def test_export_empty_media_attributes(configured_project_with_label):
77
sleep(10)
88
labels = project.label_generator()
99
label = next(labels)
10-
assert label.data.media_attributes == {}
10+
assert label.data.media_attributes == {}

tests/integration/test_data_rows.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,12 @@ def test_create_conversational_text(dataset):
719719
}
720720
examples = [
721721
{
722-
**content, 'media_type': 'CONVERSATIONAL_TEXT'
722+
**content, 'media_type': 'CONVERSATIONAL'
723723
},
724724
content,
725-
content['row_data'] # Old way to check for backwards compatibility
725+
{
726+
"conversationalData": content['row_data']['messages']
727+
} # Old way to check for backwards compatibility
726728
]
727729
dataset.create_data_rows_sync(examples)
728730
data_rows = list(dataset.data_rows())
@@ -754,7 +756,7 @@ def test_invalid_media_type(dataset):
754756
"Found invalid contents for media type: 'IMAGE'", 'IMAGE'
755757
], ["Found invalid media type: 'totallyinvalid'", 'totallyinvalid']]:
756758
# TODO: What error kind should this be? It looks like for global key we are
757-
# using malformed query. But for FileUploads we use InvalidQueryError
759+
# using malformed query. But for invalid contents in FileUploads we use InvalidQueryError
758760
with pytest.raises(labelbox.exceptions.InvalidQueryError):
759761
dataset.create_data_rows_sync([{
760762
**content, 'media_type': invalid_media_type

0 commit comments

Comments
 (0)