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

Commit 03639eb

Browse files
committed
Add logs in the __init__ file
1 parent 11c2ef3 commit 03639eb

File tree

9 files changed

+40
-75
lines changed

9 files changed

+40
-75
lines changed

bigframes/bigquery/__init__.py

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
such as array functions:
1717
https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions. """
1818

19+
import sys
20+
1921
from bigframes.bigquery._operations.approx_agg import approx_top_count
2022
from bigframes.bigquery._operations.array import (
2123
array_agg,
@@ -52,43 +54,43 @@
5254
from bigframes.bigquery._operations.search import create_vector_index, vector_search
5355
from bigframes.bigquery._operations.sql import sql_scalar
5456
from bigframes.bigquery._operations.struct import struct
57+
from bigframes.core import log_adapter
5558

56-
__all__ = [
57-
# approximate aggregate ops
58-
"approx_top_count",
59-
# array ops
60-
"array_agg",
61-
"array_length",
62-
"array_to_string",
63-
# datetime ops
64-
"unix_micros",
65-
"unix_millis",
66-
"unix_seconds",
67-
# geo ops
68-
"st_area",
69-
"st_buffer",
70-
"st_centroid",
71-
"st_convexhull",
72-
"st_difference",
73-
"st_distance",
74-
"st_intersection",
75-
"st_isclosed",
76-
"st_length",
77-
# json ops
78-
"json_extract",
79-
"json_extract_array",
80-
"json_extract_string_array",
81-
"json_query",
82-
"json_query_array",
83-
"json_set",
84-
"json_value",
85-
"json_value_array",
86-
"parse_json",
87-
# search ops
88-
"create_vector_index",
89-
"vector_search",
90-
# sql ops
91-
"sql_scalar",
92-
# struct ops
93-
"struct",
59+
_functions = [
60+
approx_top_count,
61+
array_agg,
62+
array_length,
63+
array_to_string,
64+
unix_micros,
65+
unix_millis,
66+
unix_seconds,
67+
st_area,
68+
st_buffer,
69+
st_centroid,
70+
st_convexhull,
71+
st_difference,
72+
st_distance,
73+
st_intersection,
74+
st_isclosed,
75+
st_length,
76+
json_extract,
77+
json_extract_array,
78+
json_extract_string_array,
79+
json_query,
80+
json_query_array,
81+
json_set,
82+
json_value,
83+
json_value_array,
84+
parse_json,
85+
create_vector_index,
86+
vector_search,
87+
sql_scalar,
88+
struct,
9489
]
90+
91+
__all__ = [f.__name__ for f in _functions]
92+
93+
_module = sys.modules[__name__]
94+
for f in _functions:
95+
_decorated_object = log_adapter.method_logger(f, custom_base_name="bigquery")
96+
setattr(_module, f.__name__, _decorated_object)

bigframes/bigquery/_operations/approx_agg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from __future__ import annotations
1616

17-
from bigframes.core import log_adapter
1817
import bigframes.operations.aggregations as agg_ops
1918
import bigframes.series as series
2019

@@ -24,7 +23,6 @@
2423
"""
2524

2625

27-
@log_adapter.method_logger
2826
def approx_top_count(
2927
series: series.Series,
3028
number: int,

bigframes/bigquery/_operations/array.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import bigframes_vendored.constants as constants
2626

27-
from bigframes.core import log_adapter
2827
import bigframes.core.groupby as groupby
2928
import bigframes.operations as ops
3029
import bigframes.operations.aggregations as agg_ops
@@ -34,7 +33,6 @@
3433
import bigframes.dataframe as dataframe
3534

3635

37-
@log_adapter.method_logger
3836
def array_length(series: series.Series) -> series.Series:
3937
"""Compute the length of each array element in the Series.
4038
@@ -70,7 +68,6 @@ def array_length(series: series.Series) -> series.Series:
7068
return series._apply_unary_op(ops.len_op)
7169

7270

73-
@log_adapter.method_logger
7471
def array_agg(
7572
obj: groupby.SeriesGroupBy | groupby.DataFrameGroupBy,
7673
) -> series.Series | dataframe.DataFrame:
@@ -124,7 +121,6 @@ def array_agg(
124121
)
125122

126123

127-
@log_adapter.method_logger
128124
def array_to_string(series: series.Series, delimiter: str) -> series.Series:
129125
"""Converts array elements within a Series into delimited strings.
130126

bigframes/bigquery/_operations/datetime.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
from bigframes import operations as ops
1616
from bigframes import series
17-
from bigframes.core import log_adapter
1817

1918

20-
@log_adapter.method_logger
2119
def unix_seconds(input: series.Series) -> series.Series:
2220
"""Converts a timestmap series to unix epoch seconds
2321
@@ -45,7 +43,6 @@ def unix_seconds(input: series.Series) -> series.Series:
4543
return input._apply_unary_op(ops.UnixSeconds())
4644

4745

48-
@log_adapter.method_logger
4946
def unix_millis(input: series.Series) -> series.Series:
5047
"""Converts a timestmap series to unix epoch milliseconds
5148
@@ -73,7 +70,6 @@ def unix_millis(input: series.Series) -> series.Series:
7370
return input._apply_unary_op(ops.UnixMillis())
7471

7572

76-
@log_adapter.method_logger
7773
def unix_micros(input: series.Series) -> series.Series:
7874
"""Converts a timestmap series to unix epoch microseconds
7975

bigframes/bigquery/_operations/geo.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import shapely # type: ignore
2020

2121
from bigframes import operations as ops
22-
from bigframes.core import log_adapter
2322
import bigframes.geopandas
2423
import bigframes.series
2524

@@ -29,7 +28,6 @@
2928
"""
3029

3130

32-
@log_adapter.method_logger
3331
def st_area(
3432
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
3533
) -> bigframes.series.Series:
@@ -105,7 +103,6 @@ def st_area(
105103
return series
106104

107105

108-
@log_adapter.method_logger
109106
def st_buffer(
110107
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
111108
buffer_radius: float,
@@ -175,7 +172,6 @@ def st_buffer(
175172
return series
176173

177174

178-
@log_adapter.method_logger
179175
def st_centroid(
180176
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
181177
) -> bigframes.series.Series:
@@ -233,7 +229,6 @@ def st_centroid(
233229
return series
234230

235231

236-
@log_adapter.method_logger
237232
def st_convexhull(
238233
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
239234
) -> bigframes.series.Series:
@@ -289,7 +284,6 @@ def st_convexhull(
289284
return series
290285

291286

292-
@log_adapter.method_logger
293287
def st_difference(
294288
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
295289
other: Union[
@@ -393,7 +387,6 @@ def st_difference(
393387
return series._apply_binary_op(other, ops.geo_st_difference_op)
394388

395389

396-
@log_adapter.method_logger
397390
def st_distance(
398391
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
399392
other: Union[
@@ -471,7 +464,6 @@ def st_distance(
471464
)
472465

473466

474-
@log_adapter.method_logger
475467
def st_intersection(
476468
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
477469
other: Union[
@@ -571,7 +563,6 @@ def st_intersection(
571563
return series._apply_binary_op(other, ops.geo_st_intersection_op)
572564

573565

574-
@log_adapter.method_logger
575566
def st_isclosed(
576567
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
577568
) -> bigframes.series.Series:
@@ -632,7 +623,6 @@ def st_isclosed(
632623
return series
633624

634625

635-
@log_adapter.method_logger
636626
def st_length(
637627
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
638628
*,

bigframes/bigquery/_operations/json.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from typing import Any, cast, Optional, Sequence, Tuple, Union
2525
import warnings
2626

27-
from bigframes.core import log_adapter
2827
import bigframes.core.utils as utils
2928
import bigframes.dtypes
3029
import bigframes.exceptions as bfe
@@ -34,7 +33,6 @@
3433
from . import array
3534

3635

37-
@log_adapter.method_logger
3836
@utils.preview(name="The JSON-related API `json_set`")
3937
def json_set(
4038
input: series.Series,
@@ -87,7 +85,6 @@ def json_set(
8785
return result
8886

8987

90-
@log_adapter.method_logger
9188
def json_extract(
9289
input: series.Series,
9390
json_path: str,
@@ -128,7 +125,6 @@ def json_extract(
128125
return input._apply_unary_op(ops.JSONExtract(json_path=json_path))
129126

130127

131-
@log_adapter.method_logger
132128
def json_extract_array(
133129
input: series.Series,
134130
json_path: str = "$",
@@ -188,7 +184,6 @@ def json_extract_array(
188184
return input._apply_unary_op(ops.JSONExtractArray(json_path=json_path))
189185

190186

191-
@log_adapter.method_logger
192187
def json_extract_string_array(
193188
input: series.Series,
194189
json_path: str = "$",
@@ -265,7 +260,6 @@ def json_extract_string_array(
265260
return array_series
266261

267262

268-
@log_adapter.method_logger
269263
def json_query(
270264
input: series.Series,
271265
json_path: str,
@@ -297,7 +291,6 @@ def json_query(
297291
return input._apply_unary_op(ops.JSONQuery(json_path=json_path))
298292

299293

300-
@log_adapter.method_logger
301294
def json_query_array(
302295
input: series.Series,
303296
json_path: str = "$",
@@ -348,7 +341,6 @@ def json_query_array(
348341
return input._apply_unary_op(ops.JSONQueryArray(json_path=json_path))
349342

350343

351-
@log_adapter.method_logger
352344
def json_value(
353345
input: series.Series,
354346
json_path: str = "$",
@@ -383,7 +375,6 @@ def json_value(
383375
return input._apply_unary_op(ops.JSONValue(json_path=json_path))
384376

385377

386-
@log_adapter.method_logger
387378
def json_value_array(
388379
input: series.Series,
389380
json_path: str = "$",
@@ -439,7 +430,6 @@ def json_value_array(
439430
return input._apply_unary_op(ops.JSONValueArray(json_path=json_path))
440431

441432

442-
@log_adapter.method_logger
443433
@utils.preview(name="The JSON-related API `parse_json`")
444434
def parse_json(
445435
input: series.Series,

bigframes/bigquery/_operations/search.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import google.cloud.bigquery as bigquery
2222

23-
from bigframes.core import log_adapter
2423
import bigframes.ml.utils as utils
2524

2625
if typing.TYPE_CHECKING:
@@ -34,7 +33,6 @@
3433
"""
3534

3635

37-
@log_adapter.method_logger
3836
def create_vector_index(
3937
table_id: str,
4038
column_name: str,
@@ -90,7 +88,6 @@ def create_vector_index(
9088
read_gbq_query(sql)
9189

9290

93-
@log_adapter.method_logger
9491
def vector_search(
9592
base_table: str,
9693
column_to_search: str,

bigframes/bigquery/_operations/sql.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020

2121
import google.cloud.bigquery
2222

23-
from bigframes.core import log_adapter
2423
import bigframes.core.compile.sqlglot.sqlglot_ir as sqlglot_ir
2524
import bigframes.dtypes
2625
import bigframes.operations
2726
import bigframes.series
2827

2928

30-
@log_adapter.method_logger
3129
def sql_scalar(
3230
sql_template: str,
3331
columns: Sequence[bigframes.series.Series],

bigframes/bigquery/_operations/struct.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222

2323
import typing
2424

25-
from bigframes.core import log_adapter
2625
import bigframes.operations as ops
2726
import bigframes.series as series
2827

2928
if typing.TYPE_CHECKING:
3029
import bigframes.dataframe as dataframe
3130

3231

33-
@log_adapter.method_logger
3432
def struct(value: dataframe.DataFrame) -> series.Series:
3533
"""Takes a DataFrame and converts it into a Series of structs with each
3634
struct entry corresponding to a DataFrame row and each struct field

0 commit comments

Comments
 (0)