Skip to content

Commit 45c1b82

Browse files
GarrettWushuoweil
authored andcommitted
chore: add experimental blob.display to support audio and video (#1291)
* chore: add experimental blob.display to support audio and videos * fix * fix
1 parent 25ddc64 commit 45c1b82

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bigframes/operations/blob.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def display(self, n: int = 3, *, content_type: str = ""):
156156
n (int, default 3): number of sample blob objects to display.
157157
content_type (str, default ""): content type of the blob. If unset, use the blob metadata of the storage. Possible values are "image", "audio" and "video".
158158
"""
159+
import bigframes.bigquery as bbq
160+
159161
# col name doesn't matter here. Rename to avoid column name conflicts
160162
df = bigframes.series.Series(self._block).rename("blob_col").head(n).to_frame()
161163

@@ -185,7 +187,11 @@ def display_single_url(read_url: str, content_type: str):
185187
ipy_display.display(response.content, raw=True)
186188

187189
for _, row in df.iterrows():
188-
display_single_url(row["read_url"], row["content_type"])
190+
# both are JSON-formated strings
191+
read_url = str(row["read_url"]).strip('"')
192+
content_type = str(row["content_type"]).strip('"')
193+
194+
display_single_url(read_url, content_type)
189195

190196
def image_blur(
191197
self,

0 commit comments

Comments
 (0)