Skip to content

Commit

Permalink
fix: move third_party.bigframes_vendored to bigframes_vendored (#424
Browse files Browse the repository at this point in the history
)

This will avoid potential conflicts when run from a location that contains the commonly named `third_party` directory.

Note: I followed the instructions here: https://stackoverflow.com/a/17179022/101923 but I also had to add a `pyproject.toml` file to support editable installations (see: https://togithub.com/pypa/setuptools/issues/230#issuecomment-1473278299).

Fixes internal issue 328781348.
🦕
  • Loading branch information
tswast authored Mar 12, 2024
1 parent 4aadff4 commit 763edeb
Show file tree
Hide file tree
Showing 57 changed files with 152 additions and 138 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
recursive-include third_party *
recursive-include third_party/bigframes_vendored *
recursive-include bigframes *.json *.proto py.typed
recursive-include tests *
global-exclude *.py[co]
Expand Down
3 changes: 2 additions & 1 deletion bigframes/_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
DataFrames from this package.
"""

import bigframes_vendored.pandas._config.config as pandas_config

import bigframes._config.bigquery_options as bigquery_options
import bigframes._config.compute_options as compute_options
import bigframes._config.display_options as display_options
import bigframes._config.sampling_options as sampling_options
import third_party.bigframes_vendored.pandas._config.config as pandas_config


class Options:
Expand Down
3 changes: 1 addition & 2 deletions bigframes/_config/display_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import dataclasses
from typing import Literal, Optional

import bigframes_vendored.pandas.core.config_init as vendored_pandas_config
import pandas as pd

import third_party.bigframes_vendored.pandas.core.config_init as vendored_pandas_config


@dataclasses.dataclass
class DisplayOptions:
Expand Down
2 changes: 1 addition & 1 deletion bigframes/_config/sampling_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import dataclasses
from typing import Literal, Optional

import third_party.bigframes_vendored.pandas.core.config_init as vendored_pandas_config
import bigframes_vendored.pandas.core.config_init as vendored_pandas_config


@dataclasses.dataclass
Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from typing import Iterable, List, Mapping, Optional, Sequence, Tuple
import warnings

import bigframes_vendored.pandas.io.common as vendored_pandas_io_common
import google.cloud.bigquery as bigquery
import pandas as pd

Expand All @@ -45,7 +46,6 @@
import bigframes.operations as ops
import bigframes.operations.aggregations as agg_ops
import bigframes.session._io.pandas
import third_party.bigframes_vendored.pandas.io.common as vendored_pandas_io_common

# Type constraint for wherever column labels are used
Label = typing.Hashable
Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/compile/aggregate_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import typing
from typing import cast, Optional

import bigframes_vendored.ibis.expr.operations as vendored_ibis_ops
import ibis
import ibis.expr.datatypes as ibis_dtypes
import ibis.expr.types as ibis_types
Expand All @@ -26,7 +27,6 @@
import bigframes.core.window_spec as window_spec
import bigframes.dtypes as dtypes
import bigframes.operations.aggregations as agg_ops
import third_party.bigframes_vendored.ibis.expr.operations as vendored_ibis_ops

scalar_compiler = scalar_compilers.scalar_op_compiler

Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/groupby/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import typing

import bigframes_vendored.pandas.core.groupby as vendored_pandas_groupby
import pandas as pd

import bigframes.constants as constants
Expand All @@ -30,7 +31,6 @@
import bigframes.dtypes as dtypes
import bigframes.operations.aggregations as agg_ops
import bigframes.series as series
import third_party.bigframes_vendored.pandas.core.groupby as vendored_pandas_groupby


@log_adapter.class_logger
Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/indexes/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import typing
from typing import Hashable, Optional, Sequence, Union

import bigframes_vendored.pandas.core.indexes.base as vendored_pandas_index
import google.cloud.bigquery as bigquery
import numpy as np
import pandas
Expand All @@ -33,7 +34,6 @@
import bigframes.formatting_helpers as formatter
import bigframes.operations as ops
import bigframes.operations.aggregations as agg_ops
import third_party.bigframes_vendored.pandas.core.indexes.base as vendored_pandas_index

if typing.TYPE_CHECKING:
import bigframes.dataframe
Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from datetime import datetime
from typing import Optional, Union

import bigframes_vendored.pandas.core.tools.datetimes as vendored_pandas_datetimes
import pandas as pd

import bigframes.constants as constants
import bigframes.core.global_session as global_session
import bigframes.dataframe
import bigframes.operations as ops
import bigframes.series
import third_party.bigframes_vendored.pandas.core.tools.datetimes as vendored_pandas_datetimes


def to_datetime(
Expand Down
3 changes: 1 addition & 2 deletions bigframes/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import typing
from typing import Hashable, Iterable, List

import bigframes_vendored.pandas.io.common as vendored_pandas_io_common
import pandas as pd
import typing_extensions

import third_party.bigframes_vendored.pandas.io.common as vendored_pandas_io_common

UNNAMED_COLUMN_ID = "bigframes_unnamed_column"
UNNAMED_INDEX_ID = "bigframes_unnamed_index"

Expand Down
3 changes: 2 additions & 1 deletion bigframes/core/window/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import typing

import bigframes_vendored.pandas.core.window.rolling as vendored_pandas_rolling

from bigframes.core import log_adapter
import bigframes.core as core
import bigframes.core.blocks as blocks
import bigframes.operations.aggregations as agg_ops
import third_party.bigframes_vendored.pandas.core.window.rolling as vendored_pandas_rolling


@log_adapter.class_logger
Expand Down
4 changes: 2 additions & 2 deletions bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
Union,
)

import bigframes_vendored.pandas.core.frame as vendored_pandas_frame
import bigframes_vendored.pandas.pandas._typing as vendored_pandas_typing
import google.api_core.exceptions
import google.cloud.bigquery as bigquery
import numpy
Expand Down Expand Up @@ -63,8 +65,6 @@
import bigframes.series
import bigframes.series as bf_series
import bigframes.session._io.bigquery
import third_party.bigframes_vendored.pandas.core.frame as vendored_pandas_frame
import third_party.bigframes_vendored.pandas.pandas._typing as vendored_pandas_typing

if typing.TYPE_CHECKING:
import bigframes.session
Expand Down
6 changes: 3 additions & 3 deletions bigframes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import typing
from typing import Any, Dict, Iterable, Literal, Tuple, Union

import bigframes_vendored.google_cloud_bigquery._pandas_helpers as gcb3p_pandas_helpers
import bigframes_vendored.ibis.backends.bigquery.datatypes as third_party_ibis_bqtypes
import bigframes_vendored.ibis.expr.operations as vendored_ibis_ops
import geopandas as gpd # type: ignore
import google.cloud.bigquery as bigquery
import ibis
Expand All @@ -31,9 +34,6 @@
import pyarrow as pa

import bigframes.constants as constants
import third_party.bigframes_vendored.google_cloud_bigquery._pandas_helpers as gcb3p_pandas_helpers
import third_party.bigframes_vendored.ibis.backends.bigquery.datatypes as third_party_ibis_bqtypes
import third_party.bigframes_vendored.ibis.expr.operations as vendored_ibis_ops

# Type hints for Pandas dtypes supported by BigQuery DataFrame
Dtype = Union[
Expand Down
2 changes: 1 addition & 1 deletion bigframes/functions/remote_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
if TYPE_CHECKING:
from bigframes.session import Session

import bigframes_vendored.ibis.backends.bigquery.datatypes as third_party_ibis_bqtypes
import cloudpickle
import google.api_core.exceptions
import google.api_core.retry
Expand All @@ -47,7 +48,6 @@
from bigframes import clients
import bigframes.constants as constants
import bigframes.dtypes
import third_party.bigframes_vendored.ibis.backends.bigquery.datatypes as third_party_ibis_bqtypes

logger = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions bigframes/ml/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
import abc
from typing import cast, Optional, TypeVar, Union

import bigframes_vendored.sklearn.base

from bigframes.ml import core
import bigframes.pandas as bpd
import third_party.bigframes_vendored.sklearn.base


class BaseEstimator(third_party.bigframes_vendored.sklearn.base.BaseEstimator, abc.ABC):
class BaseEstimator(bigframes_vendored.sklearn.base.BaseEstimator, abc.ABC):
"""
A BigQuery DataFrames machine learning component following the SKLearn API
design Ref: https://bit.ly/3NyhKjN
Expand Down Expand Up @@ -80,7 +81,7 @@ def __repr__(self):

# Estimator pretty printer adapted from Sklearn's, which is in turn an adaption of
# the inbuilt pretty-printer in CPython
import third_party.bigframes_vendored.cpython._pprint as adapted_pprint
import bigframes_vendored.cpython._pprint as adapted_pprint

prettyprinter = adapted_pprint._EstimatorPrettyPrinter(
compact=True, indent=1, indent_at_name=True, n_max_elements_to_show=30
Expand Down
6 changes: 3 additions & 3 deletions bigframes/ml/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@

from typing import Dict, List, Optional, Union

import bigframes_vendored.sklearn.cluster._kmeans
from google.cloud import bigquery

import bigframes
from bigframes.core import log_adapter
from bigframes.ml import base, core, globals, utils
import bigframes.pandas as bpd
import third_party.bigframes_vendored.sklearn.cluster._kmeans


@log_adapter.class_logger
class KMeans(
base.UnsupervisedTrainablePredictor,
third_party.bigframes_vendored.sklearn.cluster._kmeans.KMeans,
bigframes_vendored.sklearn.cluster._kmeans.KMeans,
):

__doc__ = third_party.bigframes_vendored.sklearn.cluster._kmeans.KMeans.__doc__
__doc__ = bigframes_vendored.sklearn.cluster._kmeans.KMeans.__doc__

def __init__(self, n_clusters: int = 8):
self.n_clusters = n_clusters
Expand Down
7 changes: 4 additions & 3 deletions bigframes/ml/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import typing
from typing import List, Optional, Tuple, Union

import bigframes_vendored.sklearn.compose._column_transformer

from bigframes import constants
from bigframes.core import log_adapter
from bigframes.ml import base, core, globals, preprocessing, utils
import bigframes.pandas as bpd
import third_party.bigframes_vendored.sklearn.compose._column_transformer

CompilablePreprocessorType = Union[
preprocessing.OneHotEncoder,
Expand All @@ -40,10 +41,10 @@
@log_adapter.class_logger
class ColumnTransformer(
base.Transformer,
third_party.bigframes_vendored.sklearn.compose._column_transformer.ColumnTransformer,
bigframes_vendored.sklearn.compose._column_transformer.ColumnTransformer,
):
__doc__ = (
third_party.bigframes_vendored.sklearn.compose._column_transformer.ColumnTransformer.__doc__
bigframes_vendored.sklearn.compose._column_transformer.ColumnTransformer.__doc__
)

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions bigframes/ml/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

from typing import List, Optional, Union

import bigframes_vendored.sklearn.decomposition._pca
from google.cloud import bigquery

import bigframes
from bigframes.core import log_adapter
from bigframes.ml import base, core, globals, utils
import bigframes.pandas as bpd
import third_party.bigframes_vendored.sklearn.decomposition._pca


@log_adapter.class_logger
class PCA(
base.UnsupervisedTrainablePredictor,
third_party.bigframes_vendored.sklearn.decomposition._pca.PCA,
bigframes_vendored.sklearn.decomposition._pca.PCA,
):
__doc__ = third_party.bigframes_vendored.sklearn.decomposition._pca.PCA.__doc__
__doc__ = bigframes_vendored.sklearn.decomposition._pca.PCA.__doc__

def __init__(self, n_components: int = 3):
self.n_components = n_components
Expand Down
24 changes: 10 additions & 14 deletions bigframes/ml/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

from typing import Dict, List, Literal, Optional, Union

import bigframes_vendored.sklearn.ensemble._forest
import bigframes_vendored.xgboost.sklearn
from google.cloud import bigquery

import bigframes
from bigframes.core import log_adapter
from bigframes.ml import base, core, globals, utils
import bigframes.pandas as bpd
import third_party.bigframes_vendored.sklearn.ensemble._forest
import third_party.bigframes_vendored.xgboost.sklearn

_BQML_PARAMS_MAPPING = {
"booster": "boosterType",
Expand All @@ -51,9 +51,9 @@
@log_adapter.class_logger
class XGBRegressor(
base.SupervisedTrainablePredictor,
third_party.bigframes_vendored.xgboost.sklearn.XGBRegressor,
bigframes_vendored.xgboost.sklearn.XGBRegressor,
):
__doc__ = third_party.bigframes_vendored.xgboost.sklearn.XGBRegressor.__doc__
__doc__ = bigframes_vendored.xgboost.sklearn.XGBRegressor.__doc__

def __init__(
self,
Expand Down Expand Up @@ -208,10 +208,10 @@ def to_gbq(self, model_name: str, replace: bool = False) -> XGBRegressor:
@log_adapter.class_logger
class XGBClassifier(
base.SupervisedTrainablePredictor,
third_party.bigframes_vendored.xgboost.sklearn.XGBClassifier,
bigframes_vendored.xgboost.sklearn.XGBClassifier,
):

__doc__ = third_party.bigframes_vendored.xgboost.sklearn.XGBClassifier.__doc__
__doc__ = bigframes_vendored.xgboost.sklearn.XGBClassifier.__doc__

def __init__(
self,
Expand Down Expand Up @@ -364,12 +364,10 @@ def to_gbq(self, model_name: str, replace: bool = False) -> XGBClassifier:
@log_adapter.class_logger
class RandomForestRegressor(
base.SupervisedTrainablePredictor,
third_party.bigframes_vendored.sklearn.ensemble._forest.RandomForestRegressor,
bigframes_vendored.sklearn.ensemble._forest.RandomForestRegressor,
):

__doc__ = (
third_party.bigframes_vendored.sklearn.ensemble._forest.RandomForestRegressor.__doc__
)
__doc__ = bigframes_vendored.sklearn.ensemble._forest.RandomForestRegressor.__doc__

def __init__(
self,
Expand Down Expand Up @@ -531,12 +529,10 @@ def to_gbq(self, model_name: str, replace: bool = False) -> RandomForestRegresso
@log_adapter.class_logger
class RandomForestClassifier(
base.SupervisedTrainablePredictor,
third_party.bigframes_vendored.sklearn.ensemble._forest.RandomForestClassifier,
bigframes_vendored.sklearn.ensemble._forest.RandomForestClassifier,
):

__doc__ = (
third_party.bigframes_vendored.sklearn.ensemble._forest.RandomForestClassifier.__doc__
)
__doc__ = bigframes_vendored.sklearn.ensemble._forest.RandomForestClassifier.__doc__

def __init__(
self,
Expand Down
Loading

0 comments on commit 763edeb

Please sign in to comment.