Skip to content
Merged
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
9 changes: 9 additions & 0 deletions labelbox/schema/data_row.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from typing import TYPE_CHECKING
import json

from labelbox.orm import query
from labelbox.orm.db_object import DbObject, Updateable, BulkDeletable
Expand Down Expand Up @@ -64,6 +65,14 @@ def __init__(self, *args, **kwargs):
self.attachments.supports_filtering = False
self.attachments.supports_sorting = False

def update(self, **kwargs):
# Convert row data to string if it is an object
# All other updates pass through
row_data = kwargs.get("row_data")
if isinstance(row_data, dict):
kwargs['row_data'] = json.dumps(kwargs['row_data'])
super().update(**kwargs)

@staticmethod
def bulk_delete(data_rows) -> None:
""" Deletes all the given DataRows.
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/test_data_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ def test_data_row_update(dataset, rand_gen, image_url):
data_row.update(external_id=external_id_2)
assert data_row.external_id == external_id_2

data_row.update(row_data="123")
assert data_row.row_data == "123"

# tileLayer becomes a media attribute
data_row.update(row_data={'pdfUrl': "123", "tileLayerUrl": "123"})
assert data_row.row_data == "123"


def test_data_row_filtering_sorting(dataset, image_url):
task = dataset.create_data_rows([
Expand Down