Skip to content

Commit 98e2012

Browse files
chore: remove circular import bigframes and import bigframes.pandas references (#1289)
* chore: remove circular `import bigframes` and `import bigframes.pandas` references * remove another bpd reference * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8e8adf0 commit 98e2012

File tree

16 files changed

+88
-75
lines changed

16 files changed

+88
-75
lines changed

bigframes/blob/_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import google.cloud.bigquery as bigquery
2020

21-
import bigframes
21+
import bigframes.session
2222
import bigframes.session._io.bigquery as bf_io_bigquery
2323

2424
_PYTHON_TO_BQ_TYPES = {int: "INT64", float: "FLOAT64", str: "STRING", bytes: "BYTES"}
@@ -37,7 +37,7 @@ class TransformFunction:
3737
"""Simple transform function class to deal with Python UDF."""
3838

3939
def __init__(
40-
self, func_def: FunctionDef, session: bigframes.Session, connection: str
40+
self, func_def: FunctionDef, session: bigframes.session.Session, connection: str
4141
):
4242
self._func = func_def.func
4343
self._requirements = func_def.requirements

bigframes/dataframe.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import pyarrow
4949
import tabulate
5050

51-
import bigframes
5251
import bigframes._config.display_options as display_options
5352
import bigframes.constants
5453
import bigframes.core

bigframes/ml/core.py

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

2323
from google.cloud import bigquery
2424

25-
import bigframes
2625
import bigframes.constants as constants
2726
import bigframes.formatting_helpers as formatting_helpers
2827
from bigframes.ml import sql as ml_sql
2928
import bigframes.pandas as bpd
29+
import bigframes.session
3030

3131

3232
class BaseBqml:
3333
"""Base class for BQML functionalities."""
3434

35-
def __init__(self, session: bigframes.Session):
35+
def __init__(self, session: bigframes.session.Session):
3636
self._session = session
3737
self._base_sql_generator = ml_sql.BaseSqlGenerator()
3838

bigframes/ml/decomposition.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import bigframes_vendored.sklearn.decomposition._pca
2323
from google.cloud import bigquery
2424

25-
import bigframes
2625
from bigframes.core import log_adapter
2726
from bigframes.ml import base, core, globals, utils
2827
import bigframes.pandas as bpd
28+
import bigframes.session
2929

3030
_BQML_PARAMS_MAPPING = {"svd_solver": "pcaSolver"}
3131

@@ -49,7 +49,9 @@ def __init__(
4949
self._bqml_model_factory = globals.bqml_model_factory()
5050

5151
@classmethod
52-
def _from_bq(cls, session: bigframes.Session, bq_model: bigquery.Model) -> PCA:
52+
def _from_bq(
53+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
54+
) -> PCA:
5355
assert bq_model.model_type == "PCA"
5456

5557
kwargs = utils.retrieve_params_from_bq_model(

bigframes/ml/ensemble.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import bigframes_vendored.xgboost.sklearn
2424
from google.cloud import bigquery
2525

26-
import bigframes
2726
from bigframes.core import log_adapter
27+
import bigframes.dataframe
2828
from bigframes.ml import base, core, globals, utils
29-
import bigframes.pandas as bpd
29+
import bigframes.session
3030

3131
_BQML_PARAMS_MAPPING = {
3232
"booster": "boosterType",
@@ -102,7 +102,7 @@ def __init__(
102102

103103
@classmethod
104104
def _from_bq(
105-
cls, session: bigframes.Session, bq_model: bigquery.Model
105+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
106106
) -> XGBRegressor:
107107
assert bq_model.model_type == "BOOSTED_TREE_REGRESSOR"
108108

@@ -169,7 +169,7 @@ def _fit(
169169
def predict(
170170
self,
171171
X: utils.ArrayType,
172-
) -> bpd.DataFrame:
172+
) -> bigframes.dataframe.DataFrame:
173173
if not self._bqml_model:
174174
raise RuntimeError("A model must be fitted before predict")
175175
(X,) = utils.batch_convert_to_dataframe(X, session=self._bqml_model.session)
@@ -261,7 +261,7 @@ def __init__(
261261

262262
@classmethod
263263
def _from_bq(
264-
cls, session: bigframes.Session, bq_model: bigquery.Model
264+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
265265
) -> XGBClassifier:
266266
assert bq_model.model_type == "BOOSTED_TREE_CLASSIFIER"
267267

@@ -325,7 +325,7 @@ def _fit(
325325
)
326326
return self
327327

328-
def predict(self, X: utils.ArrayType) -> bpd.DataFrame:
328+
def predict(self, X: utils.ArrayType) -> bigframes.dataframe.DataFrame:
329329
if not self._bqml_model:
330330
raise RuntimeError("A model must be fitted before predict")
331331
(X,) = utils.batch_convert_to_dataframe(X, session=self._bqml_model.session)
@@ -410,7 +410,7 @@ def __init__(
410410

411411
@classmethod
412412
def _from_bq(
413-
cls, session: bigframes.Session, bq_model: bigquery.Model
413+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
414414
) -> RandomForestRegressor:
415415
assert bq_model.model_type == "RANDOM_FOREST_REGRESSOR"
416416

@@ -474,7 +474,7 @@ def _fit(
474474
def predict(
475475
self,
476476
X: utils.ArrayType,
477-
) -> bpd.DataFrame:
477+
) -> bigframes.dataframe.DataFrame:
478478
if not self._bqml_model:
479479
raise RuntimeError("A model must be fitted before predict")
480480
(X,) = utils.batch_convert_to_dataframe(X, session=self._bqml_model.session)
@@ -576,7 +576,7 @@ def __init__(
576576

577577
@classmethod
578578
def _from_bq(
579-
cls, session: bigframes.Session, bq_model: bigquery.Model
579+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
580580
) -> RandomForestClassifier:
581581
assert bq_model.model_type == "RANDOM_FOREST_CLASSIFIER"
582582

@@ -640,7 +640,7 @@ def _fit(
640640
def predict(
641641
self,
642642
X: utils.ArrayType,
643-
) -> bpd.DataFrame:
643+
) -> bigframes.dataframe.DataFrame:
644644
if not self._bqml_model:
645645
raise RuntimeError("A model must be fitted before predict")
646646
(X,) = utils.batch_convert_to_dataframe(X, session=self._bqml_model.session)

bigframes/ml/forecasting.py

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

2121
from google.cloud import bigquery
2222

23-
import bigframes
2423
from bigframes.core import log_adapter
2524
from bigframes.ml import base, core, globals, utils
2625
import bigframes.pandas as bpd
26+
import bigframes.session
2727

2828
_BQML_PARAMS_MAPPING = {
2929
"horizon": "horizon",
@@ -133,7 +133,7 @@ def __init__(
133133

134134
@classmethod
135135
def _from_bq(
136-
cls, session: bigframes.Session, bq_model: bigquery.Model
136+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
137137
) -> ARIMAPlus:
138138
assert bq_model.model_type == "ARIMA_PLUS"
139139

bigframes/ml/imported.py

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

2121
from google.cloud import bigquery
2222

23-
import bigframes
2423
from bigframes.core import log_adapter
2524
from bigframes.ml import base, core, globals, utils
2625
import bigframes.pandas as bpd
26+
import bigframes.session
2727

2828

2929
@log_adapter.class_logger
@@ -41,7 +41,7 @@ def __init__(
4141
self,
4242
model_path: str,
4343
*,
44-
session: Optional[bigframes.Session] = None,
44+
session: Optional[bigframes.session.Session] = None,
4545
):
4646
self.session = session or bpd.get_global_session()
4747
self.model_path = model_path
@@ -56,7 +56,7 @@ def _create_bqml_model(self):
5656

5757
@classmethod
5858
def _from_bq(
59-
cls, session: bigframes.Session, bq_model: bigquery.Model
59+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
6060
) -> TensorFlowModel:
6161
assert bq_model.model_type == "TENSORFLOW"
6262

@@ -120,7 +120,7 @@ def __init__(
120120
self,
121121
model_path: str,
122122
*,
123-
session: Optional[bigframes.Session] = None,
123+
session: Optional[bigframes.session.Session] = None,
124124
):
125125
self.session = session or bpd.get_global_session()
126126
self.model_path = model_path
@@ -135,7 +135,7 @@ def _create_bqml_model(self):
135135

136136
@classmethod
137137
def _from_bq(
138-
cls, session: bigframes.Session, bq_model: bigquery.Model
138+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
139139
) -> ONNXModel:
140140
assert bq_model.model_type == "ONNX"
141141

@@ -218,7 +218,7 @@ def __init__(
218218
*,
219219
input: Mapping[str, str] = {},
220220
output: Mapping[str, str] = {},
221-
session: Optional[bigframes.Session] = None,
221+
session: Optional[bigframes.session.Session] = None,
222222
):
223223
self.session = session or bpd.get_global_session()
224224
self.model_path = model_path
@@ -251,7 +251,7 @@ def _create_bqml_model(self):
251251

252252
@classmethod
253253
def _from_bq(
254-
cls, session: bigframes.Session, bq_model: bigquery.Model
254+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
255255
) -> XGBoostModel:
256256
assert bq_model.model_type == "XGBOOST"
257257

bigframes/ml/linear_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
import bigframes_vendored.sklearn.linear_model._logistic
2525
from google.cloud import bigquery
2626

27-
import bigframes
2827
from bigframes.core import log_adapter
2928
from bigframes.ml import base, core, globals, utils
3029
import bigframes.pandas as bpd
30+
import bigframes.session
3131

3232
_BQML_PARAMS_MAPPING = {
3333
"optimize_strategy": "optimizationStrategy",
@@ -87,7 +87,7 @@ def __init__(
8787

8888
@classmethod
8989
def _from_bq(
90-
cls, session: bigframes.Session, bq_model: bigquery.Model
90+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
9191
) -> LinearRegression:
9292
assert bq_model.model_type == "LINEAR_REGRESSION"
9393

@@ -282,7 +282,7 @@ def __init__(
282282

283283
@classmethod
284284
def _from_bq(
285-
cls, session: bigframes.Session, bq_model: bigquery.Model
285+
cls, session: bigframes.session.Session, bq_model: bigquery.Model
286286
) -> LogisticRegression:
287287
assert bq_model.model_type == "LOGISTIC_REGRESSION"
288288

0 commit comments

Comments
 (0)