Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 2e22558

Browse files
committed
docs: Update multimodal notebook to use internal runtime helper
1 parent 61c17e3 commit 2e22558

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

notebooks/multimodal/multimodal_dataframe.ipynb

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
},
9393
{
9494
"cell_type": "code",
95-
"execution_count": 9,
95+
"execution_count": null,
9696
"metadata": {
9797
"colab": {
9898
"base_uri": "https://localhost:8080/"
@@ -128,6 +128,38 @@
128128
"import bigframes.bigquery as bbq"
129129
]
130130
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": null,
134+
"metadata": {},
135+
"outputs": [],
136+
"source": [
137+
"import bigframes.operations as ops\n",
138+
"\n",
139+
"def get_runtime_json_str(series, mode=\"R\", with_metadata=False):\n",
140+
" \"\"\"\n",
141+
" Get the runtime (contains signed URL to access gcs data) and apply the\n",
142+
" ToJSONSTring transformation.\n",
143+
" \n",
144+
" Args:\n",
145+
" series: bigframes.series.Series to operate on.\n",
146+
" mode: \"R\" for read, \"RW\" for read/write.\n",
147+
" with_metadata: Whether to fetch and include blob metadata.\n",
148+
" \"\"\"\n",
149+
" # 1. Optionally fetch metadata\n",
150+
" s = (\n",
151+
" series._apply_unary_op(ops.obj_fetch_metadata_op)\n",
152+
" if with_metadata\n",
153+
" else series\n",
154+
" )\n",
155+
" \n",
156+
" # 2. Retrieve the access URL runtime object\n",
157+
" runtime = s._apply_unary_op(ops.ObjGetAccessUrl(mode=mode))\n",
158+
" \n",
159+
" # 3. Convert the runtime object to a JSON string\n",
160+
" return runtime._apply_unary_op(ops.ToJSONString())"
161+
]
162+
},
131163
{
132164
"cell_type": "markdown",
133165
"metadata": {
@@ -1638,7 +1670,7 @@
16381670
"\n",
16391671
"# Generate a JSON string containing the runtime information (including signed read URLs)\n",
16401672
"# This allows the UDF to download the images from Google Cloud Storage\n",
1641-
"access_urls = exif_image_df[\"blob_col\"].blob.get_runtime_json_str(mode=\"R\")\n",
1673+
"access_urls = get_runtime_json_str(exif_image_df[\"blob_col\"], mode=\"R\")\n",
16421674
"\n",
16431675
"# Apply the BigQuery Python UDF to the runtime JSON strings\n",
16441676
"# We cast to string to ensure the input matches the UDF's signature\n",
@@ -1670,7 +1702,7 @@
16701702
"name": "python",
16711703
"nbconvert_exporter": "python",
16721704
"pygments_lexer": "ipython3",
1673-
"version": "3.13.0"
1705+
"version": "3.10.15"
16741706
}
16751707
},
16761708
"nbformat": 4,

0 commit comments

Comments
 (0)