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

Commit 66e21ec

Browse files
test: Fix ingress settings for vpc tests to not use "all" (#2519)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent 2e5311e commit 66e21ec

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

tests/system/large/functions/test_remote_function.py

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ def square(x):
12301230

12311231

12321232
@pytest.mark.flaky(retries=2, delay=120)
1233-
def test_remote_function_via_session_custom_sa(scalars_dfs):
1233+
def test_remote_function_via_session_custom_sa(scalars_pandas_df_index):
12341234
# TODO(shobs): Automate the following set-up during testing in the test project.
12351235
#
12361236
# For upfront convenience, the following set up has been statically created
@@ -1249,14 +1249,13 @@ def test_remote_function_via_session_custom_sa(scalars_dfs):
12491249
rf_session = bigframes.Session(context=bigframes.BigQueryOptions(project=project))
12501250

12511251
try:
1252-
# TODO(shobs): Figure out why the default ingress setting
1253-
# (internal-only) does not work here
1252+
12541253
@rf_session.remote_function(
12551254
input_types=[int],
12561255
output_type=int,
12571256
reuse=False,
12581257
cloud_function_service_account=gcf_service_account,
1259-
cloud_function_ingress_settings="all",
1258+
cloud_function_ingress_settings="internal-and-gclb",
12601259
)
12611260
def double_num(x):
12621261
if x is None:
@@ -1270,13 +1269,12 @@ def double_num(x):
12701269
assert gcf.service_config.service_account_email == gcf_service_account
12711270

12721271
# assert that the function works as expected on data
1273-
scalars_df, scalars_pandas_df = scalars_dfs
12741272

1275-
bf_int64_col = scalars_df["int64_col"]
1273+
bf_int64_col = rf_session.read_pandas(scalars_pandas_df_index.int64_col)
12761274
bf_result_col = bf_int64_col.apply(double_num)
12771275
bf_result = bf_int64_col.to_frame().assign(result=bf_result_col).to_pandas()
12781276

1279-
pd_int64_col = scalars_pandas_df["int64_col"]
1277+
pd_int64_col = scalars_pandas_df_index.int64_col
12801278
pd_result_col = pd_int64_col.apply(lambda x: x if x is None else x + x)
12811279
pd_result = pd_int64_col.to_frame().assign(result=pd_result_col)
12821280

@@ -1303,7 +1301,7 @@ def double_num(x):
13031301
)
13041302
@pytest.mark.flaky(retries=2, delay=120)
13051303
def test_remote_function_via_session_custom_build_sa(
1306-
scalars_dfs, set_build_service_account
1304+
set_build_service_account, scalars_pandas_df_index
13071305
):
13081306
# TODO(shobs): Automate the following set-up during testing in the test project.
13091307
#
@@ -1321,15 +1319,14 @@ def test_remote_function_via_session_custom_build_sa(
13211319
rf_session = bigframes.Session(context=bigframes.BigQueryOptions(project=project))
13221320

13231321
try:
1324-
# TODO(shobs): Figure out why the default ingress setting
1325-
# (internal-only) does not work here
1322+
13261323
@rf_session.remote_function(
13271324
input_types=[int],
13281325
output_type=int,
13291326
reuse=False,
13301327
cloud_function_service_account="default",
13311328
cloud_build_service_account=set_build_service_account,
1332-
cloud_function_ingress_settings="all",
1329+
cloud_function_ingress_settings="internal-and-gclb",
13331330
)
13341331
def double_num(x):
13351332
if x is None:
@@ -1342,14 +1339,11 @@ def double_num(x):
13421339
)
13431340
assert gcf.build_config.service_account == expected_build_service_account
13441341

1345-
# assert that the function works as expected on data
1346-
scalars_df, scalars_pandas_df = scalars_dfs
1347-
1348-
bf_int64_col = scalars_df["int64_col"]
1342+
bf_int64_col = rf_session.read_pandas(scalars_pandas_df_index.int64_col)
13491343
bf_result_col = bf_int64_col.apply(double_num)
13501344
bf_result = bf_int64_col.to_frame().assign(result=bf_result_col).to_pandas()
13511345

1352-
pd_int64_col = scalars_pandas_df["int64_col"]
1346+
pd_int64_col = scalars_pandas_df_index.int64_col
13531347
pd_result_col = pd_int64_col.apply(lambda x: x if x is None else x + x)
13541348
pd_result = pd_int64_col.to_frame().assign(result=pd_result_col)
13551349

@@ -1436,7 +1430,7 @@ def square_num(x):
14361430

14371431

14381432
@pytest.mark.flaky(retries=2, delay=120)
1439-
def test_remote_function_via_session_vpc(scalars_dfs):
1433+
def test_remote_function_via_session_vpc(scalars_pandas_df_index):
14401434
# TODO(shobs): Automate the following set-up during testing in the test project.
14411435
#
14421436
# For upfront convenience, the following set up has been statically created
@@ -1466,16 +1460,14 @@ def double_num(x):
14661460
return x
14671461
return x + x
14681462

1469-
# TODO(shobs): See if the test vpc can be configured to make this flow
1470-
# work with the default ingress setting (internal-only)
14711463
double_num_remote = rf_session.remote_function(
14721464
input_types=[int],
14731465
output_type=int,
14741466
reuse=False,
14751467
cloud_function_service_account="default",
14761468
cloud_function_vpc_connector=gcf_vpc_connector,
14771469
cloud_function_vpc_connector_egress_settings="all",
1478-
cloud_function_ingress_settings="all",
1470+
cloud_function_ingress_settings="internal-and-gclb",
14791471
)(double_num)
14801472

14811473
gcf = rf_session.cloudfunctionsclient.get_function(
@@ -1489,15 +1481,12 @@ def double_num(x):
14891481
# cloud_function_vpc_connector_egress_settings="all" earlier.
14901482
assert gcf.service_config.vpc_connector_egress_settings == 2
14911483

1492-
# assert that the function works as expected on data
1493-
scalars_df, scalars_pandas_df = scalars_dfs
1494-
1495-
bf_int64_col = scalars_df["int64_col"]
1484+
bf_int64_col = rf_session.read_pandas(scalars_pandas_df_index.int64_col)
14961485
bf_result_col = bf_int64_col.apply(double_num_remote)
14971486
bf_result = bf_int64_col.to_frame().assign(result=bf_result_col).to_pandas()
14981487

1499-
pd_int64_col = scalars_pandas_df["int64_col"]
1500-
pd_result_col = pd_int64_col.apply(double_num).astype("Int64")
1488+
pd_int64_col = scalars_pandas_df_index.int64_col
1489+
pd_result_col = pd_int64_col.apply(double_num)
15011490
pd_result = pd_int64_col.to_frame().assign(result=pd_result_col)
15021491

15031492
assert_frame_equal(bf_result, pd_result, check_dtype=False)

0 commit comments

Comments
 (0)