Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Merged
Changes from 1 commit
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
38 changes: 35 additions & 3 deletions notebooks/multimodal/multimodal_dataframe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -128,6 +128,38 @@
"import bigframes.bigquery as bbq"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import bigframes.operations as ops\n",
"\n",
"def get_runtime_json_str(series, mode=\"R\", with_metadata=False):\n",
" \"\"\"\n",
" Get the runtime (contains signed URL to access gcs data) and apply the\n",
" ToJSONSTring transformation.\n",
" \n",
" Args:\n",
" series: bigframes.series.Series to operate on.\n",
" mode: \"R\" for read, \"RW\" for read/write.\n",
" with_metadata: Whether to fetch and include blob metadata.\n",
" \"\"\"\n",
" # 1. Optionally fetch metadata\n",
" s = (\n",
" series._apply_unary_op(ops.obj_fetch_metadata_op)\n",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to expose internal functions like _apply_unary_op or ops.*.

Use external functions like bbq.to_json_string etc.

" if with_metadata\n",
" else series\n",
" )\n",
" \n",
" # 2. Retrieve the access URL runtime object\n",
" runtime = s._apply_unary_op(ops.ObjGetAccessUrl(mode=mode))\n",
" \n",
" # 3. Convert the runtime object to a JSON string\n",
" return runtime._apply_unary_op(ops.ToJSONString())"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -1638,7 +1670,7 @@
"\n",
"# Generate a JSON string containing the runtime information (including signed read URLs)\n",
"# This allows the UDF to download the images from Google Cloud Storage\n",
"access_urls = exif_image_df[\"blob_col\"].blob.get_runtime_json_str(mode=\"R\")\n",
"access_urls = get_runtime_json_str(exif_image_df[\"blob_col\"], mode=\"R\")\n",
"\n",
"# Apply the BigQuery Python UDF to the runtime JSON strings\n",
"# We cast to string to ensure the input matches the UDF's signature\n",
Expand Down Expand Up @@ -1670,7 +1702,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
"version": "3.10.15"
}
},
"nbformat": 4,
Expand Down
Loading