Skip to content

Commit 3fef147

Browse files
authored
refactor: rename the bigframes function classes (#1323)
* refactor: rename the bigframes function classes * resolve comments * quick fix * fix naming convention
1 parent ef4f491 commit 3fef147

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

bigframes/functions/_function_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@
5454
)
5555

5656

57-
class RemoteFunctionClient:
57+
class FunctionClient:
5858
# Wait time (in seconds) for an IAM binding to take effect after creation
5959
_iam_wait_seconds = 120
6060

61+
# TODO(b/392707725): Convert all necessary parameters for cloud function
62+
# deployment into method parameters.
6163
def __init__(
6264
self,
6365
gcp_project_id,

bigframes/functions/_function_session.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@
5555
from . import _function_client, _utils
5656

5757

58-
class RemoteFunctionSession:
59-
"""Session to manage remote functions."""
58+
class FunctionSession:
59+
"""Session to manage bigframes functions."""
6060

6161
def __init__(self):
62-
# Session level mapping of remote function artifacts
62+
# Session level mapping of function artifacts
6363
self._temp_artifacts: Dict[str, str] = dict()
6464

6565
# Lock to synchronize the update of the session artifacts
6666
self._artifacts_lock = threading.Lock()
6767

6868
def _update_temp_artifacts(self, bqrf_routine: str, gcf_path: str):
69-
"""Update remote function artifacts in the current session."""
69+
"""Update function artifacts in the current session."""
7070
with self._artifacts_lock:
7171
self._temp_artifacts[bqrf_routine] = gcf_path
7272

@@ -76,11 +76,11 @@ def clean_up(
7676
gcfclient: functions_v2.FunctionServiceClient,
7777
session_id: str,
7878
):
79-
"""Delete remote function artifacts in the current session."""
79+
"""Delete function artifacts in the current session."""
8080
with self._artifacts_lock:
8181
for bqrf_routine, gcf_path in self._temp_artifacts.items():
82-
# Let's accept the possibility that the remote function may have
83-
# been deleted directly by the user
82+
# Let's accept the possibility that the function may have been
83+
# deleted directly by the user
8484
bqclient.delete_routine(bqrf_routine, not_found_ok=True)
8585

8686
# Let's accept the possibility that the cloud function may have
@@ -467,7 +467,7 @@ def wrapper(func):
467467
signature, input_types, output_type # type: ignore
468468
)
469469

470-
remote_function_client = _function_client.RemoteFunctionClient(
470+
remote_function_client = _function_client.FunctionClient(
471471
dataset_ref.project,
472472
cloud_function_region,
473473
cloud_functions_client,

bigframes/functions/_utils.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import bigframes.core.compile.ibis_types
3131
import bigframes.dtypes
3232

33-
# Naming convention for the remote function artifacts
34-
_BIGFRAMES_REMOTE_FUNCTION_PREFIX = "bigframes"
33+
# Naming convention for the function artifacts
34+
_BIGFRAMES_FUNCTION_PREFIX = "bigframes"
3535
_BQ_FUNCTION_NAME_SEPERATOR = "_"
3636
_GCF_FUNCTION_NAME_SEPERATOR = "-"
3737

@@ -66,10 +66,10 @@ def _get_updated_package_requirements(
6666
):
6767
requirements = [f"cloudpickle=={cloudpickle.__version__}"]
6868
if is_row_processor:
69-
# bigframes remote function will send an entire row of data as json,
70-
# which would be converted to a pandas series and processed
71-
# Ensure numpy versions match to avoid unpickling problems. See
72-
# internal issue b/347934471.
69+
# bigframes function will send an entire row of data as json, which
70+
# would be converted to a pandas series and processed Ensure numpy
71+
# versions match to avoid unpickling problems. See internal issue
72+
# b/347934471.
7373
requirements.append(f"numpy=={numpy.__version__}")
7474
requirements.append(f"pandas=={pandas.__version__}")
7575
requirements.append(f"pyarrow=={pyarrow.__version__}")
@@ -94,14 +94,14 @@ def _clean_up_by_session_id(
9494
point in time.
9595
"""
9696

97-
# First clean up the BQ remote functions and then the underlying
98-
# cloud functions, so that at no point we are left with a remote function
99-
# that is pointing to a cloud function that does not exist
97+
# First clean up the BQ remote functions and then the underlying cloud
98+
# functions, so that at no point we are left with a remote function that is
99+
# pointing to a cloud function that does not exist
100100

101101
endpoints_to_be_deleted: Set[str] = set()
102102
match_prefix = "".join(
103103
[
104-
_BIGFRAMES_REMOTE_FUNCTION_PREFIX,
104+
_BIGFRAMES_FUNCTION_PREFIX,
105105
_BQ_FUNCTION_NAME_SEPERATOR,
106106
session_id,
107107
_BQ_FUNCTION_NAME_SEPERATOR,
@@ -176,7 +176,7 @@ def routine_ref_to_string_for_query(routine_ref: bigquery.RoutineReference) -> s
176176

177177
def get_cloud_function_name(function_hash, session_id=None, uniq_suffix=None):
178178
"Get a name for the cloud function for the given user defined function."
179-
parts = [_BIGFRAMES_REMOTE_FUNCTION_PREFIX]
179+
parts = [_BIGFRAMES_FUNCTION_PREFIX]
180180
if session_id:
181181
parts.append(session_id)
182182
parts.append(function_hash)
@@ -186,8 +186,8 @@ def get_cloud_function_name(function_hash, session_id=None, uniq_suffix=None):
186186

187187

188188
def get_remote_function_name(function_hash, session_id, uniq_suffix=None):
189-
"Get a name for the BQ remote function for the given user defined function."
190-
parts = [_BIGFRAMES_REMOTE_FUNCTION_PREFIX, session_id, function_hash]
189+
"Get a name for the remote function for the given user defined function."
190+
parts = [_BIGFRAMES_FUNCTION_PREFIX, session_id, function_hash]
191191
if uniq_suffix:
192192
parts.append(uniq_suffix)
193193
return _BQ_FUNCTION_NAME_SEPERATOR.join(parts)

bigframes/functions/function.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ def get_routine_reference(
120120

121121

122122
def remote_function(*args, **kwargs):
123-
remote_function_session = bff_session.RemoteFunctionSession()
123+
remote_function_session = bff_session.FunctionSession()
124124
return remote_function_session.remote_function(*args, **kwargs)
125125

126126

127-
remote_function.__doc__ = bff_session.RemoteFunctionSession.remote_function.__doc__
127+
remote_function.__doc__ = bff_session.FunctionSession.remote_function.__doc__
128128

129129

130130
def read_gbq_function(
@@ -174,7 +174,7 @@ def read_gbq_function(
174174
# The name "args" conflicts with the Ibis operator, so we use
175175
# non-standard names for the arguments here.
176176
def func(*bigframes_args, **bigframes_kwargs):
177-
f"""Remote function {str(routine_ref)}."""
177+
f"""Bigframes function {str(routine_ref)}."""
178178
nonlocal node # type: ignore
179179

180180
expr = node(*bigframes_args, **bigframes_kwargs) # type: ignore

bigframes/session/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def __init__(
245245
)
246246

247247
self._metrics = bigframes.session.metrics.ExecutionMetrics()
248-
self._function_session = bff_session.RemoteFunctionSession()
248+
self._function_session = bff_session.FunctionSession()
249249
self._temp_storage_manager = (
250250
bigframes.session.temp_storage.TemporaryGbqStorageManager(
251251
self._clients_provider.bqclient,

0 commit comments

Comments
 (0)