From 1255173de5c9d11cc897e3cbf3353b46b43776fa Mon Sep 17 00:00:00 2001 From: Shenyang Cai Date: Mon, 12 Jan 2026 21:54:11 +0000 Subject: [PATCH] refactor: move log_adapter.py under logging/ directory --- bigframes/bigquery/__init__.py | 2 +- bigframes/bigquery/_operations/ai.py | 3 ++- bigframes/bigquery/_operations/ml.py | 2 +- bigframes/core/groupby/dataframe_group_by.py | 2 +- bigframes/core/groupby/series_group_by.py | 2 +- bigframes/core/logging/__init__.py | 17 +++++++++++++++++ bigframes/core/{ => logging}/log_adapter.py | 0 bigframes/core/window/rolling.py | 3 ++- bigframes/dataframe.py | 3 ++- bigframes/ml/cluster.py | 2 +- bigframes/ml/compose.py | 2 +- bigframes/ml/decomposition.py | 2 +- bigframes/ml/ensemble.py | 2 +- bigframes/ml/forecasting.py | 2 +- bigframes/ml/imported.py | 2 +- bigframes/ml/impute.py | 2 +- bigframes/ml/linear_model.py | 2 +- bigframes/ml/llm.py | 3 ++- bigframes/ml/model_selection.py | 2 +- bigframes/ml/pipeline.py | 2 +- bigframes/ml/preprocessing.py | 2 +- bigframes/ml/remote.py | 3 ++- bigframes/operations/ai.py | 3 ++- bigframes/operations/blob.py | 2 +- bigframes/operations/datetimes.py | 2 +- bigframes/operations/lists.py | 2 +- bigframes/operations/plotting.py | 2 +- bigframes/operations/semantics.py | 3 ++- bigframes/operations/strings.py | 2 +- bigframes/operations/structs.py | 3 ++- bigframes/pandas/__init__.py | 2 +- bigframes/series.py | 3 ++- bigframes/session/__init__.py | 3 ++- bigframes/session/_io/bigquery/__init__.py | 2 +- bigframes/streaming/__init__.py | 2 +- bigframes/streaming/dataframe.py | 3 ++- tests/unit/core/logging/__init__.py | 13 +++++++++++++ .../unit/core/{ => logging}/test_log_adapter.py | 2 +- tests/unit/session/test_io_bigquery.py | 2 +- 39 files changed, 77 insertions(+), 36 deletions(-) create mode 100644 bigframes/core/logging/__init__.py rename bigframes/core/{ => logging}/log_adapter.py (100%) create mode 100644 tests/unit/core/logging/__init__.py rename tests/unit/core/{ => logging}/test_log_adapter.py (99%) diff --git a/bigframes/bigquery/__init__.py b/bigframes/bigquery/__init__.py index f835285a21..7a7a01a8fc 100644 --- a/bigframes/bigquery/__init__.py +++ b/bigframes/bigquery/__init__.py @@ -60,7 +60,7 @@ from bigframes.bigquery._operations.search import create_vector_index, vector_search from bigframes.bigquery._operations.sql import sql_scalar from bigframes.bigquery._operations.struct import struct -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter _functions = [ # approximate aggregate ops diff --git a/bigframes/bigquery/_operations/ai.py b/bigframes/bigquery/_operations/ai.py index e8c28e61f5..e56292d64f 100644 --- a/bigframes/bigquery/_operations/ai.py +++ b/bigframes/bigquery/_operations/ai.py @@ -26,7 +26,8 @@ from bigframes import clients, dataframe, dtypes from bigframes import pandas as bpd from bigframes import series, session -from bigframes.core import convert, log_adapter +from bigframes.core import convert +from bigframes.core.logging import log_adapter from bigframes.ml import core as ml_core from bigframes.operations import ai_ops, output_schemas diff --git a/bigframes/bigquery/_operations/ml.py b/bigframes/bigquery/_operations/ml.py index 073be0ef2b..c9b48bb5ac 100644 --- a/bigframes/bigquery/_operations/ml.py +++ b/bigframes/bigquery/_operations/ml.py @@ -20,7 +20,7 @@ import google.cloud.bigquery import pandas as pd -import bigframes.core.log_adapter as log_adapter +import bigframes.core.logging.log_adapter as log_adapter import bigframes.core.sql.ml import bigframes.dataframe as dataframe import bigframes.ml.base diff --git a/bigframes/core/groupby/dataframe_group_by.py b/bigframes/core/groupby/dataframe_group_by.py index e3a132d4d0..7f9e5d627a 100644 --- a/bigframes/core/groupby/dataframe_group_by.py +++ b/bigframes/core/groupby/dataframe_group_by.py @@ -26,10 +26,10 @@ from bigframes import session from bigframes.core import agg_expressions from bigframes.core import expression as ex -from bigframes.core import log_adapter import bigframes.core.block_transforms as block_ops import bigframes.core.blocks as blocks from bigframes.core.groupby import aggs, group_by, series_group_by +from bigframes.core.logging import log_adapter import bigframes.core.ordering as order import bigframes.core.utils as utils import bigframes.core.validations as validations diff --git a/bigframes/core/groupby/series_group_by.py b/bigframes/core/groupby/series_group_by.py index b1485888a8..a8900cf545 100644 --- a/bigframes/core/groupby/series_group_by.py +++ b/bigframes/core/groupby/series_group_by.py @@ -25,10 +25,10 @@ from bigframes import session from bigframes.core import expression as ex -from bigframes.core import log_adapter import bigframes.core.block_transforms as block_ops import bigframes.core.blocks as blocks from bigframes.core.groupby import aggs, group_by +from bigframes.core.logging import log_adapter import bigframes.core.ordering as order import bigframes.core.utils as utils import bigframes.core.validations as validations diff --git a/bigframes/core/logging/__init__.py b/bigframes/core/logging/__init__.py new file mode 100644 index 0000000000..95c077a99a --- /dev/null +++ b/bigframes/core/logging/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from bigframes.core.logging import log_adapter + +__all__ = ["log_adapter"] diff --git a/bigframes/core/log_adapter.py b/bigframes/core/logging/log_adapter.py similarity index 100% rename from bigframes/core/log_adapter.py rename to bigframes/core/logging/log_adapter.py diff --git a/bigframes/core/window/rolling.py b/bigframes/core/window/rolling.py index d6c77bf0a7..b7bb62372c 100644 --- a/bigframes/core/window/rolling.py +++ b/bigframes/core/window/rolling.py @@ -24,8 +24,9 @@ from bigframes import dtypes from bigframes.core import agg_expressions from bigframes.core import expression as ex -from bigframes.core import log_adapter, ordering, utils, window_spec +from bigframes.core import ordering, utils, window_spec import bigframes.core.blocks as blocks +from bigframes.core.logging import log_adapter from bigframes.core.window import ordering as window_ordering import bigframes.operations.aggregations as agg_ops diff --git a/bigframes/dataframe.py b/bigframes/dataframe.py index 9efc6ba061..e1ad4f3e75 100644 --- a/bigframes/dataframe.py +++ b/bigframes/dataframe.py @@ -55,7 +55,7 @@ import bigframes.constants import bigframes.core -from bigframes.core import agg_expressions, log_adapter +from bigframes.core import agg_expressions import bigframes.core.block_transforms as block_ops import bigframes.core.blocks as blocks import bigframes.core.convert @@ -66,6 +66,7 @@ import bigframes.core.indexers as indexers import bigframes.core.indexes as indexes import bigframes.core.interchange +from bigframes.core.logging import log_adapter import bigframes.core.ordering as order import bigframes.core.utils as utils import bigframes.core.validations as validations diff --git a/bigframes/ml/cluster.py b/bigframes/ml/cluster.py index 9ce4649c5e..f371be0cf3 100644 --- a/bigframes/ml/cluster.py +++ b/bigframes/ml/cluster.py @@ -24,7 +24,7 @@ import pandas as pd import bigframes -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd diff --git a/bigframes/ml/compose.py b/bigframes/ml/compose.py index 54ce7066cb..d638e026e4 100644 --- a/bigframes/ml/compose.py +++ b/bigframes/ml/compose.py @@ -27,8 +27,8 @@ import bigframes_vendored.sklearn.compose._column_transformer from google.cloud import bigquery -from bigframes.core import log_adapter import bigframes.core.compile.googlesql as sql_utils +from bigframes.core.logging import log_adapter import bigframes.core.utils as core_utils from bigframes.ml import base, core, globals, impute, preprocessing, utils import bigframes.pandas as bpd diff --git a/bigframes/ml/decomposition.py b/bigframes/ml/decomposition.py index 3ff32d2433..ca5ff102b4 100644 --- a/bigframes/ml/decomposition.py +++ b/bigframes/ml/decomposition.py @@ -23,7 +23,7 @@ import bigframes_vendored.sklearn.decomposition._pca from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd import bigframes.session diff --git a/bigframes/ml/ensemble.py b/bigframes/ml/ensemble.py index 2633f13411..7cd7079dfb 100644 --- a/bigframes/ml/ensemble.py +++ b/bigframes/ml/ensemble.py @@ -23,7 +23,7 @@ import bigframes_vendored.xgboost.sklearn from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.dataframe from bigframes.ml import base, core, globals, utils import bigframes.session diff --git a/bigframes/ml/forecasting.py b/bigframes/ml/forecasting.py index d26abdfa71..99a7b1743d 100644 --- a/bigframes/ml/forecasting.py +++ b/bigframes/ml/forecasting.py @@ -20,7 +20,7 @@ from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd import bigframes.session diff --git a/bigframes/ml/imported.py b/bigframes/ml/imported.py index a73ee352d0..295649ed7f 100644 --- a/bigframes/ml/imported.py +++ b/bigframes/ml/imported.py @@ -20,7 +20,7 @@ from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd import bigframes.session diff --git a/bigframes/ml/impute.py b/bigframes/ml/impute.py index 818151a4f9..b3da895201 100644 --- a/bigframes/ml/impute.py +++ b/bigframes/ml/impute.py @@ -22,7 +22,7 @@ import bigframes_vendored.sklearn.impute._base -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.core.utils as core_utils from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd diff --git a/bigframes/ml/linear_model.py b/bigframes/ml/linear_model.py index 3774a62c0c..df054eb306 100644 --- a/bigframes/ml/linear_model.py +++ b/bigframes/ml/linear_model.py @@ -24,7 +24,7 @@ import bigframes_vendored.sklearn.linear_model._logistic from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd import bigframes.session diff --git a/bigframes/ml/llm.py b/bigframes/ml/llm.py index b670cabaea..0386212990 100644 --- a/bigframes/ml/llm.py +++ b/bigframes/ml/llm.py @@ -24,7 +24,8 @@ from bigframes import dtypes, exceptions import bigframes.bigquery as bbq -from bigframes.core import blocks, global_session, log_adapter +from bigframes.core import blocks, global_session +from bigframes.core.logging import log_adapter import bigframes.dataframe from bigframes.ml import base, core, globals, utils import bigframes.series diff --git a/bigframes/ml/model_selection.py b/bigframes/ml/model_selection.py index 6eba4f81c2..5adfb03b7f 100644 --- a/bigframes/ml/model_selection.py +++ b/bigframes/ml/model_selection.py @@ -26,7 +26,7 @@ import bigframes_vendored.sklearn.model_selection._validation as vendored_model_selection_validation import pandas as pd -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter from bigframes.ml import utils import bigframes.pandas as bpd diff --git a/bigframes/ml/pipeline.py b/bigframes/ml/pipeline.py index dac51b1956..8d69217694 100644 --- a/bigframes/ml/pipeline.py +++ b/bigframes/ml/pipeline.py @@ -24,7 +24,7 @@ import bigframes_vendored.sklearn.pipeline from google.cloud import bigquery -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.dataframe from bigframes.ml import ( base, diff --git a/bigframes/ml/preprocessing.py b/bigframes/ml/preprocessing.py index 94c61674f6..8bf89b0838 100644 --- a/bigframes/ml/preprocessing.py +++ b/bigframes/ml/preprocessing.py @@ -26,7 +26,7 @@ import bigframes_vendored.sklearn.preprocessing._label import bigframes_vendored.sklearn.preprocessing._polynomial -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.core.utils as core_utils from bigframes.ml import base, core, globals, utils import bigframes.pandas as bpd diff --git a/bigframes/ml/remote.py b/bigframes/ml/remote.py index b091c61f3f..24083bd4e8 100644 --- a/bigframes/ml/remote.py +++ b/bigframes/ml/remote.py @@ -19,7 +19,8 @@ from typing import Mapping, Optional import warnings -from bigframes.core import global_session, log_adapter +from bigframes.core import global_session +from bigframes.core.logging import log_adapter import bigframes.dataframe import bigframes.exceptions as bfe from bigframes.ml import base, core, globals, utils diff --git a/bigframes/operations/ai.py b/bigframes/operations/ai.py index ad58e8825c..6921299acd 100644 --- a/bigframes/operations/ai.py +++ b/bigframes/operations/ai.py @@ -20,7 +20,8 @@ import warnings from bigframes import dtypes, exceptions, options -from bigframes.core import guid, log_adapter +from bigframes.core import guid +from bigframes.core.logging import log_adapter @log_adapter.class_logger diff --git a/bigframes/operations/blob.py b/bigframes/operations/blob.py index 577de458f4..29f720b3eb 100644 --- a/bigframes/operations/blob.py +++ b/bigframes/operations/blob.py @@ -23,7 +23,7 @@ import requests from bigframes import clients, dtypes -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.dataframe import bigframes.exceptions as bfe import bigframes.operations as ops diff --git a/bigframes/operations/datetimes.py b/bigframes/operations/datetimes.py index c259dd018e..2eedb96b43 100644 --- a/bigframes/operations/datetimes.py +++ b/bigframes/operations/datetimes.py @@ -22,7 +22,7 @@ import pandas from bigframes import dataframe, dtypes, series -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.operations as ops _ONE_DAY = pandas.Timedelta("1D") diff --git a/bigframes/operations/lists.py b/bigframes/operations/lists.py index 34ecdd8118..9974e68693 100644 --- a/bigframes/operations/lists.py +++ b/bigframes/operations/lists.py @@ -19,7 +19,7 @@ import bigframes_vendored.pandas.core.arrays.arrow.accessors as vendoracessors -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.operations as ops from bigframes.operations._op_converters import convert_index, convert_slice import bigframes.series as series diff --git a/bigframes/operations/plotting.py b/bigframes/operations/plotting.py index df0c138f0f..21a23a9ab5 100644 --- a/bigframes/operations/plotting.py +++ b/bigframes/operations/plotting.py @@ -17,7 +17,7 @@ import bigframes_vendored.constants as constants import bigframes_vendored.pandas.plotting._core as vendordt -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter import bigframes.operations._matplotlib as bfplt diff --git a/bigframes/operations/semantics.py b/bigframes/operations/semantics.py index 2266702d47..f237959d0d 100644 --- a/bigframes/operations/semantics.py +++ b/bigframes/operations/semantics.py @@ -21,7 +21,8 @@ import numpy as np from bigframes import dtypes, exceptions -from bigframes.core import guid, log_adapter +from bigframes.core import guid +from bigframes.core.logging import log_adapter @log_adapter.class_logger diff --git a/bigframes/operations/strings.py b/bigframes/operations/strings.py index d84a66789d..922d26a23c 100644 --- a/bigframes/operations/strings.py +++ b/bigframes/operations/strings.py @@ -20,8 +20,8 @@ import bigframes_vendored.constants as constants import bigframes_vendored.pandas.core.strings.accessor as vendorstr -from bigframes.core import log_adapter import bigframes.core.indexes.base as indices +from bigframes.core.logging import log_adapter import bigframes.dataframe as df import bigframes.operations as ops from bigframes.operations._op_converters import convert_index, convert_slice diff --git a/bigframes/operations/structs.py b/bigframes/operations/structs.py index 35010e1733..ec0b5dae52 100644 --- a/bigframes/operations/structs.py +++ b/bigframes/operations/structs.py @@ -17,7 +17,8 @@ import bigframes_vendored.pandas.core.arrays.arrow.accessors as vendoracessors import pandas as pd -from bigframes.core import backports, log_adapter +from bigframes.core import backports +from bigframes.core.logging import log_adapter import bigframes.dataframe import bigframes.operations import bigframes.series diff --git a/bigframes/pandas/__init__.py b/bigframes/pandas/__init__.py index 0b9648fd56..9da2204a71 100644 --- a/bigframes/pandas/__init__.py +++ b/bigframes/pandas/__init__.py @@ -27,9 +27,9 @@ import pandas import bigframes._config as config -from bigframes.core import log_adapter import bigframes.core.global_session as global_session import bigframes.core.indexes +from bigframes.core.logging import log_adapter from bigframes.core.reshape.api import concat, crosstab, cut, get_dummies, merge, qcut import bigframes.dataframe import bigframes.functions._utils as bff_utils diff --git a/bigframes/series.py b/bigframes/series.py index 606169a8a1..814d59beff 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -49,13 +49,14 @@ import typing_extensions import bigframes.core -from bigframes.core import agg_expressions, groupby, log_adapter +from bigframes.core import agg_expressions, groupby import bigframes.core.block_transforms as block_ops import bigframes.core.blocks as blocks import bigframes.core.expression as ex import bigframes.core.identifiers as ids import bigframes.core.indexers import bigframes.core.indexes as indexes +from bigframes.core.logging import log_adapter import bigframes.core.ordering as order import bigframes.core.scalar as scalars import bigframes.core.utils as utils diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 4f32514652..ca8fbf2919 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -67,10 +67,11 @@ import bigframes.clients import bigframes.constants import bigframes.core -from bigframes.core import blocks, log_adapter, utils +from bigframes.core import blocks, utils import bigframes.core.events import bigframes.core.indexes import bigframes.core.indexes.multi +from bigframes.core.logging import log_adapter import bigframes.core.pyformat import bigframes.formatting_helpers import bigframes.functions._function_session as bff_session diff --git a/bigframes/session/_io/bigquery/__init__.py b/bigframes/session/_io/bigquery/__init__.py index 9114770224..98b5f194c7 100644 --- a/bigframes/session/_io/bigquery/__init__.py +++ b/bigframes/session/_io/bigquery/__init__.py @@ -32,9 +32,9 @@ import google.cloud.bigquery._job_helpers import google.cloud.bigquery.table -from bigframes.core import log_adapter import bigframes.core.compile.googlesql as googlesql import bigframes.core.events +from bigframes.core.logging import log_adapter import bigframes.core.sql import bigframes.session.metrics diff --git a/bigframes/streaming/__init__.py b/bigframes/streaming/__init__.py index 477c7a99e0..0d91e5f91a 100644 --- a/bigframes/streaming/__init__.py +++ b/bigframes/streaming/__init__.py @@ -17,8 +17,8 @@ import inspect import sys -from bigframes.core import log_adapter import bigframes.core.global_session as global_session +from bigframes.core.logging import log_adapter from bigframes.pandas.io.api import _set_default_session_location_if_possible import bigframes.session import bigframes.streaming.dataframe as streaming_dataframe diff --git a/bigframes/streaming/dataframe.py b/bigframes/streaming/dataframe.py index 3e030a4aa2..b7b67178ce 100644 --- a/bigframes/streaming/dataframe.py +++ b/bigframes/streaming/dataframe.py @@ -27,7 +27,8 @@ import pandas as pd from bigframes import dataframe -from bigframes.core import log_adapter, nodes +from bigframes.core import nodes +from bigframes.core.logging import log_adapter import bigframes.exceptions as bfe import bigframes.session diff --git a/tests/unit/core/logging/__init__.py b/tests/unit/core/logging/__init__.py new file mode 100644 index 0000000000..58d482ea38 --- /dev/null +++ b/tests/unit/core/logging/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tests/unit/core/test_log_adapter.py b/tests/unit/core/logging/test_log_adapter.py similarity index 99% rename from tests/unit/core/test_log_adapter.py rename to tests/unit/core/logging/test_log_adapter.py index c236bb6886..ecef966afc 100644 --- a/tests/unit/core/test_log_adapter.py +++ b/tests/unit/core/logging/test_log_adapter.py @@ -17,7 +17,7 @@ from google.cloud import bigquery import pytest -from bigframes.core import log_adapter +from bigframes.core.logging import log_adapter # The limit is 64 (https://cloud.google.com/bigquery/docs/labels-intro#requirements), # but leave a few spare for internal labels to be added. diff --git a/tests/unit/session/test_io_bigquery.py b/tests/unit/session/test_io_bigquery.py index 4349c1b6ee..eb58c6bb52 100644 --- a/tests/unit/session/test_io_bigquery.py +++ b/tests/unit/session/test_io_bigquery.py @@ -23,8 +23,8 @@ import pytest import bigframes -from bigframes.core import log_adapter import bigframes.core.events +from bigframes.core.logging import log_adapter import bigframes.pandas as bpd import bigframes.session._io.bigquery import bigframes.session._io.bigquery as io_bq