Skip to content

Commit 4318d66

Browse files
authored
test: re-enable Multimodal tests (#2235)
* Revert "fix: Correct connection normalization in blob system tests (#2222)" This reverts commit a0e1e50. * fix
1 parent da9ba26 commit 4318d66

File tree

6 files changed

+18
-94
lines changed

6 files changed

+18
-94
lines changed

tests/system/conftest.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,6 @@ def _hash_digest_file(hasher, filepath):
7070
hasher.update(chunk)
7171

7272

73-
@pytest.fixture(scope="session")
74-
def normalize_connection_id():
75-
"""Normalizes the connection ID by casefolding only the LOCATION component.
76-
77-
Connection format: PROJECT.LOCATION.CONNECTION_NAME
78-
Only LOCATION is case-insensitive; PROJECT and CONNECTION_NAME must be lowercase.
79-
"""
80-
81-
def normalize(connection_id: str) -> str:
82-
parts = connection_id.split(".")
83-
if len(parts) == 3:
84-
return f"{parts[0]}.{parts[1].casefold()}.{parts[2]}"
85-
return connection_id # Return unchanged if invalid format
86-
87-
return normalize
88-
89-
9073
@pytest.fixture(scope="session")
9174
def tokyo_location() -> str:
9275
return TOKYO_LOCATION
@@ -212,7 +195,8 @@ def bq_connection_name() -> str:
212195

213196
@pytest.fixture(scope="session")
214197
def bq_connection(bigquery_client: bigquery.Client, bq_connection_name: str) -> str:
215-
return f"{bigquery_client.project}.{bigquery_client.location}.{bq_connection_name}"
198+
# TODO(b/458169181): LOCATION casefold is needed for the mutimodal backend bug. Remove after the bug is fixed.
199+
return f"{bigquery_client.project}.{bigquery_client.location.casefold()}.{bq_connection_name}"
216200

217201

218202
@pytest.fixture(scope="session", autouse=True)

tests/system/large/blob/test_function.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def images_output_uris(images_output_folder: str) -> list[str]:
5252
]
5353

5454

55-
@pytest.mark.skip(reason="b/457416070")
5655
def test_blob_exif(
5756
bq_connection: str,
5857
session: bigframes.Session,
@@ -104,7 +103,6 @@ def test_blob_exif_verbose(
104103
assert content_series.dtype == dtypes.JSON_DTYPE
105104

106105

107-
@pytest.mark.skip(reason="b/457416070")
108106
def test_blob_image_blur_to_series(
109107
images_mm_df: bpd.DataFrame,
110108
bq_connection: str,
@@ -138,7 +136,6 @@ def test_blob_image_blur_to_series(
138136
assert not actual.blob.size().isna().any()
139137

140138

141-
@pytest.mark.skip(reason="b/457416070")
142139
def test_blob_image_blur_to_series_verbose(
143140
images_mm_df: bpd.DataFrame,
144141
bq_connection: str,
@@ -166,7 +163,6 @@ def test_blob_image_blur_to_series_verbose(
166163
assert not actual.blob.size().isna().any()
167164

168165

169-
@pytest.mark.skip(reason="b/457416070")
170166
def test_blob_image_blur_to_folder(
171167
images_mm_df: bpd.DataFrame,
172168
bq_connection: str,
@@ -199,7 +195,6 @@ def test_blob_image_blur_to_folder(
199195
assert not actual.blob.size().isna().any()
200196

201197

202-
@pytest.mark.skip(reason="b/457416070")
203198
def test_blob_image_blur_to_folder_verbose(
204199
images_mm_df: bpd.DataFrame,
205200
bq_connection: str,
@@ -259,7 +254,6 @@ def test_blob_image_blur_to_bq_verbose(images_mm_df: bpd.DataFrame, bq_connectio
259254
assert content_series.dtype == dtypes.BYTES_DTYPE
260255

261256

262-
@pytest.mark.skip(reason="b/457416070")
263257
def test_blob_image_resize_to_series(
264258
images_mm_df: bpd.DataFrame,
265259
bq_connection: str,
@@ -297,7 +291,6 @@ def test_blob_image_resize_to_series(
297291
assert not actual.blob.size().isna().any()
298292

299293

300-
@pytest.mark.skip(reason="b/457416070")
301294
def test_blob_image_resize_to_series_verbose(
302295
images_mm_df: bpd.DataFrame,
303296
bq_connection: str,
@@ -332,7 +325,6 @@ def test_blob_image_resize_to_series_verbose(
332325
assert not actual.blob.size().isna().any()
333326

334327

335-
@pytest.mark.skip(reason="b/457416070")
336328
def test_blob_image_resize_to_folder(
337329
images_mm_df: bpd.DataFrame,
338330
bq_connection: str,
@@ -366,7 +358,6 @@ def test_blob_image_resize_to_folder(
366358
assert not actual.blob.size().isna().any()
367359

368360

369-
@pytest.mark.skip(reason="b/457416070")
370361
def test_blob_image_resize_to_folder_verbose(
371362
images_mm_df: bpd.DataFrame,
372363
bq_connection: str,
@@ -429,7 +420,6 @@ def test_blob_image_resize_to_bq_verbose(
429420
assert content_series.dtype == dtypes.BYTES_DTYPE
430421

431422

432-
@pytest.mark.skip(reason="b/457416070")
433423
def test_blob_image_normalize_to_series(
434424
images_mm_df: bpd.DataFrame,
435425
bq_connection: str,
@@ -502,7 +492,6 @@ def test_blob_image_normalize_to_series_verbose(
502492
assert hasattr(content_series, "blob")
503493

504494

505-
@pytest.mark.skip(reason="b/457416070")
506495
def test_blob_image_normalize_to_folder(
507496
images_mm_df: bpd.DataFrame,
508497
bq_connection: str,
@@ -609,7 +598,6 @@ def test_blob_image_normalize_to_bq_verbose(
609598
assert content_series.dtype == dtypes.BYTES_DTYPE
610599

611600

612-
@pytest.mark.skip(reason="b/457416070")
613601
def test_blob_pdf_extract(
614602
pdf_mm_df: bpd.DataFrame,
615603
bq_connection: str,
@@ -645,7 +633,6 @@ def test_blob_pdf_extract(
645633
), f"Item (verbose=False): Expected keyword '{keyword}' not found in extracted text. "
646634

647635

648-
@pytest.mark.skip(reason="b/457416070")
649636
def test_blob_pdf_extract_verbose(
650637
pdf_mm_df: bpd.DataFrame,
651638
bq_connection: str,
@@ -683,7 +670,6 @@ def test_blob_pdf_extract_verbose(
683670
), f"Item (verbose=True): Expected keyword '{keyword}' not found in extracted text. "
684671

685672

686-
@pytest.mark.skip(reason="b/457416070")
687673
def test_blob_pdf_chunk(pdf_mm_df: bpd.DataFrame, bq_connection: str):
688674
actual = (
689675
pdf_mm_df["pdf"]
@@ -723,7 +709,6 @@ def test_blob_pdf_chunk(pdf_mm_df: bpd.DataFrame, bq_connection: str):
723709
), f"Item (verbose=False): Expected keyword '{keyword}' not found in extracted text. "
724710

725711

726-
@pytest.mark.skip(reason="b/457416070")
727712
def test_blob_pdf_chunk_verbose(pdf_mm_df: bpd.DataFrame, bq_connection: str):
728713
actual = (
729714
pdf_mm_df["pdf"]

tests/system/small/bigquery/test_ai.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@ def test_ai_if(session):
273273
assert result.dtype == dtypes.BOOL_DTYPE
274274

275275

276-
@pytest.mark.skip(reason="b/457416070")
277-
def test_ai_if_multi_model(session):
276+
def test_ai_if_multi_model(session, bq_connection):
278277
df = session.from_glob_path(
279-
"gs://bigframes-dev-testing/a_multimodel/images/*", name="image"
278+
"gs://bigframes-dev-testing/a_multimodel/images/*",
279+
name="image",
280+
connection=bq_connection,
280281
)
281282

282283
result = bbq.ai.if_((df["image"], " contains an animal"))
@@ -294,10 +295,11 @@ def test_ai_classify(session):
294295
assert result.dtype == dtypes.STRING_DTYPE
295296

296297

297-
@pytest.mark.skip(reason="b/457416070")
298-
def test_ai_classify_multi_model(session):
298+
def test_ai_classify_multi_model(session, bq_connection):
299299
df = session.from_glob_path(
300-
"gs://bigframes-dev-testing/a_multimodel/images/*", name="image"
300+
"gs://bigframes-dev-testing/a_multimodel/images/*",
301+
name="image",
302+
connection=bq_connection,
301303
)
302304

303305
result = bbq.ai.classify(df["image"], ["photo", "cartoon"])

tests/system/small/blob/test_io.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Callable
1615
from unittest import mock
1716

1817
import IPython.display
1918
import pandas as pd
20-
import pytest
2119

2220
import bigframes
2321
import bigframes.pandas as bpd
2422

2523

2624
def test_blob_create_from_uri_str(
27-
bq_connection: str,
28-
session: bigframes.Session,
29-
images_uris,
30-
normalize_connection_id: Callable[[str], str],
25+
bq_connection: str, session: bigframes.Session, images_uris
3126
):
3227
uri_series = bpd.Series(images_uris, session=session)
3328
blob_series = uri_series.str.to_blob(connection=bq_connection)
3429

3530
pd_blob_df = blob_series.struct.explode().to_pandas()
36-
pd_blob_df["authorizer"] = pd_blob_df["authorizer"].apply(normalize_connection_id)
3731
expected_pd_df = pd.DataFrame(
3832
{
3933
"uri": images_uris,
4034
"version": [None, None],
41-
"authorizer": [
42-
normalize_connection_id(bq_connection),
43-
normalize_connection_id(bq_connection),
44-
],
35+
"authorizer": [bq_connection.casefold(), bq_connection.casefold()],
4536
"details": [None, None],
4637
}
4738
)
@@ -52,11 +43,7 @@ def test_blob_create_from_uri_str(
5243

5344

5445
def test_blob_create_from_glob_path(
55-
bq_connection: str,
56-
session: bigframes.Session,
57-
images_gcs_path,
58-
images_uris,
59-
normalize_connection_id: Callable[[str], str],
46+
bq_connection: str, session: bigframes.Session, images_gcs_path, images_uris
6047
):
6148
blob_df = session.from_glob_path(
6249
images_gcs_path, connection=bq_connection, name="blob_col"
@@ -68,16 +55,12 @@ def test_blob_create_from_glob_path(
6855
.sort_values("uri")
6956
.reset_index(drop=True)
7057
)
71-
pd_blob_df["authorizer"] = pd_blob_df["authorizer"].apply(normalize_connection_id)
7258

7359
expected_df = pd.DataFrame(
7460
{
7561
"uri": images_uris,
7662
"version": [None, None],
77-
"authorizer": [
78-
normalize_connection_id(bq_connection),
79-
normalize_connection_id(bq_connection),
80-
],
63+
"authorizer": [bq_connection.casefold(), bq_connection.casefold()],
8164
"details": [None, None],
8265
}
8366
)
@@ -88,11 +71,7 @@ def test_blob_create_from_glob_path(
8871

8972

9073
def test_blob_create_read_gbq_object_table(
91-
bq_connection: str,
92-
session: bigframes.Session,
93-
images_gcs_path,
94-
images_uris,
95-
normalize_connection_id: Callable[[str], str],
74+
bq_connection: str, session: bigframes.Session, images_gcs_path, images_uris
9675
):
9776
obj_table = session._create_object_table(images_gcs_path, bq_connection)
9877

@@ -104,15 +83,11 @@ def test_blob_create_read_gbq_object_table(
10483
.sort_values("uri")
10584
.reset_index(drop=True)
10685
)
107-
pd_blob_df["authorizer"] = pd_blob_df["authorizer"].apply(normalize_connection_id)
10886
expected_df = pd.DataFrame(
10987
{
11088
"uri": images_uris,
11189
"version": [None, None],
112-
"authorizer": [
113-
normalize_connection_id(bq_connection),
114-
normalize_connection_id(bq_connection),
115-
],
90+
"authorizer": [bq_connection.casefold(), bq_connection.casefold()],
11691
"details": [None, None],
11792
}
11893
)
@@ -122,7 +97,6 @@ def test_blob_create_read_gbq_object_table(
12297
)
12398

12499

125-
@pytest.mark.skip(reason="b/457416070")
126100
def test_display_images(monkeypatch, images_mm_df: bpd.DataFrame):
127101
mock_display = mock.Mock()
128102
monkeypatch.setattr(IPython.display, "display", mock_display)

tests/system/small/blob/test_properties.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import annotations
16-
17-
from typing import Callable
18-
1915
import pandas as pd
20-
import pytest
2116

2217
import bigframes.dtypes as dtypes
2318
import bigframes.pandas as bpd
@@ -32,27 +27,17 @@ def test_blob_uri(images_uris: list[str], images_mm_df: bpd.DataFrame):
3227
)
3328

3429

35-
def test_blob_authorizer(
36-
images_mm_df: bpd.DataFrame,
37-
bq_connection: str,
38-
normalize_connection_id: Callable[[str], str],
39-
):
30+
def test_blob_authorizer(images_mm_df: bpd.DataFrame, bq_connection: str):
4031
actual = images_mm_df["blob_col"].blob.authorizer().to_pandas()
41-
actual = actual.apply(normalize_connection_id)
4232
expected = pd.Series(
43-
[
44-
normalize_connection_id(bq_connection),
45-
normalize_connection_id(bq_connection),
46-
],
47-
name="authorizer",
33+
[bq_connection.casefold(), bq_connection.casefold()], name="authorizer"
4834
)
4935

5036
pd.testing.assert_series_equal(
5137
actual, expected, check_dtype=False, check_index_type=False
5238
)
5339

5440

55-
@pytest.mark.skip(reason="b/457416070")
5641
def test_blob_version(images_mm_df: bpd.DataFrame):
5742
actual = images_mm_df["blob_col"].blob.version().to_pandas()
5843
expected = pd.Series(["1753907851152593", "1753907851111538"], name="version")
@@ -62,7 +47,6 @@ def test_blob_version(images_mm_df: bpd.DataFrame):
6247
)
6348

6449

65-
@pytest.mark.skip(reason="b/457416070")
6650
def test_blob_metadata(images_mm_df: bpd.DataFrame):
6751
actual = images_mm_df["blob_col"].blob.metadata().to_pandas()
6852
expected = pd.Series(
@@ -87,7 +71,6 @@ def test_blob_metadata(images_mm_df: bpd.DataFrame):
8771
pd.testing.assert_series_equal(actual, expected)
8872

8973

90-
@pytest.mark.skip(reason="b/457416070")
9174
def test_blob_content_type(images_mm_df: bpd.DataFrame):
9275
actual = images_mm_df["blob_col"].blob.content_type().to_pandas()
9376
expected = pd.Series(["image/jpeg", "image/jpeg"], name="content_type")
@@ -97,7 +80,6 @@ def test_blob_content_type(images_mm_df: bpd.DataFrame):
9780
)
9881

9982

100-
@pytest.mark.skip(reason="b/457416070")
10183
def test_blob_md5_hash(images_mm_df: bpd.DataFrame):
10284
actual = images_mm_df["blob_col"].blob.md5_hash().to_pandas()
10385
expected = pd.Series(
@@ -110,7 +92,6 @@ def test_blob_md5_hash(images_mm_df: bpd.DataFrame):
11092
)
11193

11294

113-
@pytest.mark.skip(reason="b/457416070")
11495
def test_blob_size(images_mm_df: bpd.DataFrame):
11596
actual = images_mm_df["blob_col"].blob.size().to_pandas()
11697
expected = pd.Series([338390, 43333], name="size")
@@ -120,7 +101,6 @@ def test_blob_size(images_mm_df: bpd.DataFrame):
120101
)
121102

122103

123-
@pytest.mark.skip(reason="b/457416070")
124104
def test_blob_updated(images_mm_df: bpd.DataFrame):
125105
actual = images_mm_df["blob_col"].blob.updated().to_pandas()
126106
expected = pd.Series(

tests/system/small/ml/test_multimodal_llm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from bigframes.testing import utils
2222

2323

24-
@pytest.mark.skip(reason="b/457416070")
2524
@pytest.mark.flaky(retries=2)
2625
def test_multimodal_embedding_generator_predict_default_params_success(
2726
images_mm_df, session, bq_connection

0 commit comments

Comments
 (0)