@@ -67,7 +67,7 @@ def bq_cf_connection_location_project(bigquery_client) -> str:
67
67
68
68
@pytest .fixture (scope = "module" )
69
69
def bq_cf_connection_location_project_mismatched () -> str :
70
- """Pre-created BQ connection in the migframes -metrics project in US location,
70
+ """Pre-created BQ connection in the bigframes -metrics project in US location,
71
71
in format PROJECT_ID.LOCATION.CONNECTION_NAME, used to invoke cloud function.
72
72
73
73
$ bq show --connection --location=us --project_id=PROJECT_ID bigframes-rf-conn
@@ -108,11 +108,15 @@ def test_remote_function_direct_no_session_param(
108
108
reuse = True ,
109
109
)
110
110
def square (x ):
111
- # This executes on a remote function, where coverage isn't tracked.
112
- return x * x # pragma: NO COVER
111
+ return x * x
113
112
114
- assert square .bigframes_remote_function
115
- assert square .bigframes_cloud_function
113
+ # Function should still work normally.
114
+ assert square (2 ) == 4
115
+
116
+ # Function should have extra metadata attached for remote execution.
117
+ assert hasattr (square , "bigframes_remote_function" )
118
+ assert hasattr (square , "bigframes_cloud_function" )
119
+ assert hasattr (square , "ibis_node" )
116
120
117
121
scalars_df , scalars_pandas_df = scalars_dfs
118
122
@@ -161,8 +165,10 @@ def test_remote_function_direct_no_session_param_location_specified(
161
165
reuse = True ,
162
166
)
163
167
def square (x ):
164
- # This executes on a remote function, where coverage isn't tracked.
165
- return x * x # pragma: NO COVER
168
+ return x * x
169
+
170
+ # Function should still work normally.
171
+ assert square (2 ) == 4
166
172
167
173
scalars_df , scalars_pandas_df = scalars_dfs
168
174
@@ -197,7 +203,10 @@ def test_remote_function_direct_no_session_param_location_mismatched(
197
203
dataset_id_permanent ,
198
204
bq_cf_connection_location_mismatched ,
199
205
):
200
- with pytest .raises (ValueError ):
206
+ with pytest .raises (
207
+ ValueError ,
208
+ match = re .escape ("The location does not match BigQuery connection location:" ),
209
+ ):
201
210
202
211
@rf .remote_function (
203
212
[int ],
@@ -212,7 +221,8 @@ def test_remote_function_direct_no_session_param_location_mismatched(
212
221
reuse = True ,
213
222
)
214
223
def square (x ):
215
- # This executes on a remote function, where coverage isn't tracked.
224
+ # Not expected to reach this code, as the location of the
225
+ # connection doesn't match the location of the dataset.
216
226
return x * x # pragma: NO COVER
217
227
218
228
@@ -239,8 +249,10 @@ def test_remote_function_direct_no_session_param_location_project_specified(
239
249
reuse = True ,
240
250
)
241
251
def square (x ):
242
- # This executes on a remote function, where coverage isn't tracked.
243
- return x * x # pragma: NO COVER
252
+ return x * x
253
+
254
+ # Function should still work normally.
255
+ assert square (2 ) == 4
244
256
245
257
scalars_df , scalars_pandas_df = scalars_dfs
246
258
@@ -275,7 +287,12 @@ def test_remote_function_direct_no_session_param_project_mismatched(
275
287
dataset_id_permanent ,
276
288
bq_cf_connection_location_project_mismatched ,
277
289
):
278
- with pytest .raises (ValueError ):
290
+ with pytest .raises (
291
+ ValueError ,
292
+ match = re .escape (
293
+ "The project_id does not match BigQuery connection gcp_project_id:"
294
+ ),
295
+ ):
279
296
280
297
@rf .remote_function (
281
298
[int ],
@@ -290,7 +307,8 @@ def test_remote_function_direct_no_session_param_project_mismatched(
290
307
reuse = True ,
291
308
)
292
309
def square (x ):
293
- # This executes on a remote function, where coverage isn't tracked.
310
+ # Not expected to reach this code, as the project of the
311
+ # connection doesn't match the project of the dataset.
294
312
return x * x # pragma: NO COVER
295
313
296
314
@@ -302,8 +320,10 @@ def test_remote_function_direct_session_param(session_with_bq_connection, scalar
302
320
session = session_with_bq_connection ,
303
321
)
304
322
def square (x ):
305
- # This executes on a remote function, where coverage isn't tracked.
306
- return x * x # pragma: NO COVER
323
+ return x * x
324
+
325
+ # Function should still work normally.
326
+ assert square (2 ) == 4
307
327
308
328
scalars_df , scalars_pandas_df = scalars_dfs
309
329
@@ -340,8 +360,10 @@ def test_remote_function_via_session_default(session_with_bq_connection, scalars
340
360
# cloud function would be common and quickly reused.
341
361
@session_with_bq_connection .remote_function ([int ], int )
342
362
def square (x ):
343
- # This executes on a remote function, where coverage isn't tracked.
344
- return x * x # pragma: NO COVER
363
+ return x * x
364
+
365
+ # Function should still work normally.
366
+ assert square (2 ) == 4
345
367
346
368
scalars_df , scalars_pandas_df = scalars_dfs
347
369
@@ -380,8 +402,10 @@ def test_remote_function_via_session_with_overrides(
380
402
reuse = True ,
381
403
)
382
404
def square (x ):
383
- # This executes on a remote function, where coverage isn't tracked.
384
- return x * x # pragma: NO COVER
405
+ return x * x
406
+
407
+ # Function should still work normally.
408
+ assert square (2 ) == 4
385
409
386
410
scalars_df , scalars_pandas_df = scalars_dfs
387
411
@@ -508,7 +532,7 @@ def test_skip_bq_connection_check(dataset_id_permanent):
508
532
509
533
@session .remote_function ([int ], int , dataset = dataset_id_permanent )
510
534
def add_one (x ):
511
- # This executes on a remote function, where coverage isn 't tracked .
535
+ # Not expected to reach this code, as the connection doesn 't exist .
512
536
return x + 1 # pragma: NO COVER
513
537
514
538
@@ -546,8 +570,10 @@ def test_read_gbq_function_like_original(
546
570
reuse = True ,
547
571
)
548
572
def square1 (x ):
549
- # This executes on a remote function, where coverage isn't tracked.
550
- return x * x # pragma: NO COVER
573
+ return x * x
574
+
575
+ # Function should still work normally.
576
+ assert square1 (2 ) == 4
551
577
552
578
square2 = rf .read_gbq_function (
553
579
function_name = square1 .bigframes_remote_function ,
0 commit comments