Skip to content

Commit ddbb32d

Browse files
committed
revert new session methods
1 parent dc02baf commit ddbb32d

File tree

8 files changed

+35
-212
lines changed

8 files changed

+35
-212
lines changed

bigframes/core/indexes/base.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,9 @@ def to_series(
383383

384384
name = self.name if name is None else name
385385
if index is None:
386-
return bigframes.series.Series(
387-
data=self, index=self, name=name, session=self._session
388-
)
386+
return bigframes.series.Series(data=self, index=self, name=name)
389387
else:
390-
return bigframes.series.Series(
391-
data=self,
392-
index=Index(index, session=self._session),
393-
name=name,
394-
session=self._session,
395-
)
388+
return bigframes.series.Series(data=self, index=Index(index), name=name)
396389

397390
def get_level_values(self, level) -> Index:
398391
level_n = level if isinstance(level, int) else self.names.index(level)

bigframes/core/indexes/multi.py

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import cast, Hashable, Iterable, Optional, Sequence, TYPE_CHECKING
17+
from typing import cast, Hashable, Iterable, Sequence
1818

1919
import bigframes_vendored.pandas.core.indexes.multi as vendored_pandas_multindex
2020
import pandas
@@ -23,9 +23,6 @@
2323
from bigframes.core import expression as ex
2424
from bigframes.core.indexes.base import Index
2525

26-
if TYPE_CHECKING:
27-
import bigframes.session
28-
2926

3027
class MultiIndex(Index, vendored_pandas_multindex.MultiIndex):
3128
__doc__ = vendored_pandas_multindex.MultiIndex.__doc__
@@ -36,25 +33,21 @@ def from_tuples(
3633
tuples: Iterable[tuple[Hashable, ...]],
3734
sortorder: int | None = None,
3835
names: Sequence[Hashable] | Hashable | None = None,
39-
*,
40-
session: Optional[bigframes.session.Session] = None,
4136
) -> MultiIndex:
4237
pd_index = pandas.MultiIndex.from_tuples(tuples, sortorder, names)
4338
# Index.__new__ should detect multiple levels and properly create a multiindex
44-
return cast(MultiIndex, Index(pd_index, session=session))
39+
return cast(MultiIndex, Index(pd_index))
4540

4641
@classmethod
4742
def from_arrays(
4843
cls,
4944
arrays,
5045
sortorder: int | None = None,
5146
names=None,
52-
*,
53-
session: Optional[bigframes.session.Session] = None,
5447
) -> MultiIndex:
5548
pd_index = pandas.MultiIndex.from_arrays(arrays, sortorder, names)
5649
# Index.__new__ should detect multiple levels and properly create a multiindex
57-
return cast(MultiIndex, Index(pd_index, session=session))
50+
return cast(MultiIndex, Index(pd_index))
5851

5952
def __eq__(self, other) -> Index: # type: ignore
6053
import bigframes.operations as ops
@@ -78,38 +71,3 @@ def __eq__(self, other) -> Index: # type: ignore
7871
index_labels=[None],
7972
)
8073
)
81-
82-
83-
class MultiIndexAccessor:
84-
"""Proxy to MultiIndex constructors to allow a session to be passed in."""
85-
86-
def __init__(self, session: bigframes.session.Session):
87-
self._session = session
88-
89-
def __call__(self, *args, **kwargs) -> MultiIndex:
90-
"""Construct a MultiIndex using the associated Session.
91-
92-
See :class:`bigframes.pandas.MultiIndex`.
93-
"""
94-
return MultiIndex(*args, session=self._session, **kwargs)
95-
96-
def from_arrays(self, *args, **kwargs) -> MultiIndex:
97-
"""Construct a MultiIndex using the associated Session.
98-
99-
See :func:`bigframes.pandas.MultiIndex.from_arrays`.
100-
"""
101-
return MultiIndex.from_arrays(*args, session=self._session, **kwargs)
102-
103-
def from_frame(self, *args, **kwargs) -> MultiIndex:
104-
"""Construct a MultiIndex using the associated Session.
105-
106-
See :func:`bigframes.pandas.MultiIndex.from_frame`.
107-
"""
108-
return cast(MultiIndex, MultiIndex.from_frame(*args, **kwargs))
109-
110-
def from_tuples(self, *args, **kwargs) -> MultiIndex:
111-
"""Construct a MultiIndex using the associated Session.
112-
113-
See :func:`bigframes.pandas.MultiIndex.from_tuples`.
114-
"""
115-
return MultiIndex.from_tuples(*args, session=self._session, **kwargs)

bigframes/core/log_adapter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ def method_logger(method=None, /, *, custom_base_name: Optional[str] = None):
155155
def outer_wrapper(method):
156156
@functools.wraps(method)
157157
def wrapper(*args, **kwargs):
158-
api_method_name = getattr(
159-
method, LOG_OVERRIDE_NAME, method.__name__
160-
).lower()
158+
api_method_name = getattr(method, LOG_OVERRIDE_NAME, method.__name__)
161159
if custom_base_name is None:
162160
qualname_parts = getattr(method, "__qualname__", method.__name__).split(
163161
"."

bigframes/core/reshape/tile.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from __future__ import annotations
1616

1717
import typing
18-
from typing import Optional, TYPE_CHECKING
1918

2019
import bigframes_vendored.constants as constants
2120
import bigframes_vendored.pandas.core.reshape.tile as vendored_pandas_tile
@@ -32,9 +31,6 @@
3231
import bigframes.operations.aggregations as agg_ops
3332
import bigframes.series
3433

35-
if TYPE_CHECKING:
36-
import bigframes.session
37-
3834

3935
def cut(
4036
x,
@@ -46,7 +42,6 @@ def cut(
4642
*,
4743
right: typing.Optional[bool] = True,
4844
labels: typing.Union[typing.Iterable[str], bool, None] = None,
49-
session: Optional[bigframes.session.Session] = None,
5045
) -> bigframes.series.Series:
5146
if (
5247
labels is not None
@@ -70,7 +65,7 @@ def cut(
7065
raise ValueError("Cannot cut empty array.")
7166

7267
if not isinstance(x, bigframes.series.Series):
73-
x = bigframes.series.Series(x, session=session)
68+
x = bigframes.series.Series(x)
7469

7570
if isinstance(bins, int):
7671
if bins <= 0:

bigframes/core/tools/datetimes.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import annotations
16-
1715
from collections.abc import Mapping
1816
from datetime import date, datetime
19-
from typing import Optional, TYPE_CHECKING, Union
17+
from typing import Optional, Union
2018

2119
import bigframes_vendored.constants as constants
2220
import bigframes_vendored.pandas.core.tools.datetimes as vendored_pandas_datetimes
@@ -27,9 +25,6 @@
2725
import bigframes.operations as ops
2826
import bigframes.series
2927

30-
if TYPE_CHECKING:
31-
import bigframes.session
32-
3328

3429
def to_datetime(
3530
arg: Union[
@@ -42,7 +37,6 @@ def to_datetime(
4237
utc: bool = False,
4338
format: Optional[str] = None,
4439
unit: Optional[str] = None,
45-
session: Optional[bigframes.session.Session] = None,
4640
) -> Union[pd.Timestamp, datetime, bigframes.series.Series]:
4741
if isinstance(arg, (int, float, str, datetime, date)):
4842
return pd.to_datetime(
@@ -58,7 +52,7 @@ def to_datetime(
5852
f"to datetime is not implemented. {constants.FEEDBACK_LINK}"
5953
)
6054

61-
arg = bigframes.series.Series(arg, session=session)
55+
arg = bigframes.series.Series(arg)
6256

6357
if format and unit and arg.dtype in (bigframes.dtypes.INT_DTYPE, bigframes.dtypes.FLOAT_DTYPE): # type: ignore
6458
raise ValueError("cannot specify both format and unit")

bigframes/pandas/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
from __future__ import annotations
1818

19-
import collections
20-
import datetime
19+
from collections import namedtuple
20+
from datetime import date, datetime
2121
import inspect
2222
import sys
2323
import typing
@@ -198,18 +198,18 @@ def to_datetime(
198198

199199
@typing.overload
200200
def to_datetime(
201-
arg: Union[int, float, str, datetime.datetime, datetime.date],
201+
arg: Union[int, float, str, datetime, date],
202202
*,
203203
utc: bool = False,
204204
format: Optional[str] = None,
205205
unit: Optional[str] = None,
206-
) -> Union[pandas.Timestamp, datetime.datetime]:
206+
) -> Union[pandas.Timestamp, datetime]:
207207
...
208208

209209

210210
def to_datetime(
211211
arg: Union[
212-
Union[int, float, str, datetime.datetime, datetime.date],
212+
Union[int, float, str, datetime, date],
213213
vendored_pandas_datetimes.local_iterables,
214214
bigframes.series.Series,
215215
bigframes.dataframe.DataFrame,
@@ -218,9 +218,8 @@ def to_datetime(
218218
utc: bool = False,
219219
format: Optional[str] = None,
220220
unit: Optional[str] = None,
221-
) -> Union[pandas.Timestamp, datetime.datetime, bigframes.series.Series]:
222-
return global_session.with_default_session(
223-
bigframes.session.Session.to_datetime,
221+
) -> Union[pandas.Timestamp, datetime, bigframes.series.Series]:
222+
return bigframes.core.tools.to_datetime(
224223
arg,
225224
utc=utc,
226225
format=format,
@@ -323,7 +322,7 @@ def clean_up_by_session_id(
323322
__version__ = bigframes.version.__version__
324323

325324
# Other public pandas attributes
326-
NamedAgg = collections.namedtuple("NamedAgg", ["column", "aggfunc"])
325+
NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
327326

328327
options = config.options
329328
"""Global :class:`~bigframes._config.Options` to configure BigQuery DataFrames."""

0 commit comments

Comments
 (0)