Skip to content

Commit bcac8c6

Browse files
authored
feat: allow input_types, output_type, and dataset to be used positionally in remote_function (#1560)
1 parent 4bf2e43 commit bcac8c6

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

bigframes/pandas/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@
6565

6666

6767
def remote_function(
68-
*,
68+
# Make sure that the input/output types, and dataset can be used
69+
# positionally. This avoids the worst of the breaking change from 1.x to
70+
# 2.x while still preventing possible mixups between consecutive str
71+
# parameters.
6972
input_types: Union[None, type, Sequence[type]] = None,
7073
output_type: Optional[type] = None,
7174
dataset: Optional[str] = None,
75+
*,
7276
bigquery_connection: Optional[str] = None,
7377
reuse: bool = True,
7478
name: Optional[str] = None,

bigframes/session/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1202,10 +1202,14 @@ def _check_file_size(self, filepath: str):
12021202

12031203
def remote_function(
12041204
self,
1205-
*,
1205+
# Make sure that the input/output types, and dataset can be used
1206+
# positionally. This avoids the worst of the breaking change from 1.x to
1207+
# 2.x while still preventing possible mixups between consecutive str
1208+
# parameters.
12061209
input_types: Union[None, type, Sequence[type]] = None,
12071210
output_type: Optional[type] = None,
12081211
dataset: Optional[str] = None,
1212+
*,
12091213
bigquery_connection: Optional[str] = None,
12101214
reuse: bool = True,
12111215
name: Optional[str] = None,

tests/system/large/functions/test_remote_function.py

+48-28
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ def test_remote_function_multiply_with_ibis(
109109
try:
110110

111111
@session.remote_function(
112-
input_types=[int, int],
113-
output_type=int,
114-
dataset=dataset_id,
112+
# Make sure that the input/output types can be used positionally.
113+
# This avoids the worst of the breaking change from 1.x to 2.x.
114+
[int, int],
115+
int,
116+
dataset_id,
115117
bigquery_connection=bq_cf_connection,
116118
reuse=False,
117119
cloud_function_service_account="default",
@@ -164,9 +166,11 @@ def test_remote_function_stringify_with_ibis(
164166
try:
165167

166168
@session.remote_function(
167-
input_types=[int],
168-
output_type=str,
169-
dataset=dataset_id,
169+
# Make sure that the input/output types can be used positionally.
170+
# This avoids the worst of the breaking change from 1.x to 2.x.
171+
[int],
172+
str,
173+
dataset_id,
170174
bigquery_connection=bq_cf_connection,
171175
reuse=False,
172176
cloud_function_service_account="default",
@@ -213,9 +217,11 @@ def func(x, y):
213217
return x * abs(y % 4)
214218

215219
remote_func = session.remote_function(
216-
input_types=[str, int],
217-
output_type=str,
218-
dataset=dataset_id,
220+
# Make sure that the input/output types can be used positionally.
221+
# This avoids the worst of the breaking change from 1.x to 2.x.
222+
[str, int],
223+
str,
224+
dataset_id,
219225
bigquery_connection=bq_cf_connection,
220226
reuse=False,
221227
cloud_function_service_account="default",
@@ -251,9 +257,11 @@ def func(x, y):
251257
return [len(x), abs(y % 4)]
252258

253259
remote_func = session.remote_function(
254-
input_types=[str, int],
255-
output_type=list[int],
256-
dataset=dataset_id,
260+
# Make sure that the input/output types can be used positionally.
261+
# This avoids the worst of the breaking change from 1.x to 2.x.
262+
[str, int],
263+
list[int],
264+
dataset_id,
257265
bigquery_connection=bq_cf_connection,
258266
reuse=False,
259267
cloud_function_service_account="default",
@@ -286,9 +294,11 @@ def test_remote_function_decorator_with_bigframes_series(
286294
try:
287295

288296
@session.remote_function(
289-
input_types=[int],
290-
output_type=int,
291-
dataset=dataset_id,
297+
# Make sure that the input/output types can be used positionally.
298+
# This avoids the worst of the breaking change from 1.x to 2.x.
299+
[int],
300+
int,
301+
dataset_id,
292302
bigquery_connection=bq_cf_connection,
293303
reuse=False,
294304
cloud_function_service_account="default",
@@ -333,9 +343,11 @@ def add_one(x):
333343
return x + 1
334344

335345
remote_add_one = session.remote_function(
336-
input_types=[int],
337-
output_type=int,
338-
dataset=dataset_id,
346+
# Make sure that the input/output types can be used positionally.
347+
# This avoids the worst of the breaking change from 1.x to 2.x.
348+
[int],
349+
int,
350+
dataset_id,
339351
bigquery_connection=bq_cf_connection,
340352
reuse=False,
341353
cloud_function_service_account="default",
@@ -385,8 +397,10 @@ def add_one(x):
385397
return x + 1
386398

387399
remote_add_one = session.remote_function(
388-
input_types=input_types,
389-
output_type=int,
400+
# Make sure that the input/output types can be used positionally.
401+
# This avoids the worst of the breaking change from 1.x to 2.x.
402+
input_types,
403+
int,
390404
reuse=False,
391405
cloud_function_service_account="default",
392406
)(add_one)
@@ -415,8 +429,10 @@ def test_remote_function_explicit_dataset_not_created(
415429
try:
416430

417431
@session.remote_function(
418-
input_types=[int],
419-
output_type=int,
432+
# Make sure that the input/output types can be used positionally.
433+
# This avoids the worst of the breaking change from 1.x to 2.x.
434+
[int],
435+
int,
420436
dataset=dataset_id_not_created,
421437
bigquery_connection=bq_cf_connection,
422438
reuse=False,
@@ -469,9 +485,11 @@ def sign(num):
469485
return NO_SIGN
470486

471487
remote_sign = session.remote_function(
472-
input_types=[int],
473-
output_type=int,
474-
dataset=dataset_id,
488+
# Make sure that the input/output types can be used positionally.
489+
# This avoids the worst of the breaking change from 1.x to 2.x.
490+
[int],
491+
int,
492+
dataset_id,
475493
bigquery_connection=bq_cf_connection,
476494
reuse=False,
477495
cloud_function_service_account="default",
@@ -517,9 +535,11 @@ def circumference(radius):
517535
return 2 * mymath.pi * radius
518536

519537
remote_circumference = session.remote_function(
520-
input_types=[float],
521-
output_type=float,
522-
dataset=dataset_id,
538+
# Make sure that the input/output types can be used positionally.
539+
# This avoids the worst of the breaking change from 1.x to 2.x.
540+
[float],
541+
float,
542+
dataset_id,
523543
bigquery_connection=bq_cf_connection,
524544
reuse=False,
525545
cloud_function_service_account="default",

0 commit comments

Comments
 (0)