Skip to content

Commit 817e3c4

Browse files
committed
chore: restores accidentally deleted subdirectory
1 parent 2fe755d commit 817e3c4

File tree

309 files changed

+84105
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+84105
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""BigQuery DataFrames provides a DataFrame API scaled by the BigQuery engine."""
16+
17+
import warnings
18+
19+
# Suppress Python version support warnings from google-cloud libraries.
20+
# These are particularly noisy in Colab which still uses Python 3.10.
21+
warnings.filterwarnings(
22+
"ignore",
23+
category=FutureWarning,
24+
message=".*Google will stop supporting.*Python.*",
25+
)
26+
27+
from bigframes._config import option_context, options # noqa: E402
28+
from bigframes._config.bigquery_options import BigQueryOptions # noqa: E402
29+
from bigframes.core.global_session import ( # noqa: E402
30+
close_session,
31+
get_global_session,
32+
)
33+
import bigframes.enums as enums # noqa: E402
34+
import bigframes.exceptions as exceptions # noqa: E402
35+
from bigframes.session import connect, Session # noqa: E402
36+
from bigframes.version import __version__ # noqa: E402
37+
38+
_MAGIC_NAMES = ["bqsql"]
39+
40+
41+
def load_ipython_extension(ipython):
42+
"""Called by IPython when this module is loaded as an IPython extension."""
43+
# Requires IPython to be installed for import to succeed
44+
from bigframes._magics import _cell_magic
45+
46+
for magic_name in _MAGIC_NAMES:
47+
ipython.register_magic_function(
48+
_cell_magic, magic_kind="cell", magic_name=magic_name
49+
)
50+
51+
52+
__all__ = [
53+
"options",
54+
"BigQueryOptions",
55+
"get_global_session",
56+
"close_session",
57+
"enums",
58+
"exceptions",
59+
"connect",
60+
"Session",
61+
"__version__",
62+
"option_context",
63+
]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Configuration for BigQuery DataFrames. Do not depend on other parts of BigQuery
17+
DataFrames from this package.
18+
"""
19+
20+
from bigframes._config.bigquery_options import BigQueryOptions
21+
from bigframes._config.compute_options import ComputeOptions
22+
from bigframes._config.display_options import DisplayOptions
23+
from bigframes._config.experiment_options import ExperimentOptions
24+
from bigframes._config.global_options import option_context, Options
25+
import bigframes._config.global_options as global_options
26+
from bigframes._config.sampling_options import SamplingOptions
27+
28+
options = global_options.options
29+
"""Global options for the default session."""
30+
31+
__all__ = (
32+
"Options",
33+
"options",
34+
"option_context",
35+
"BigQueryOptions",
36+
"ComputeOptions",
37+
"DisplayOptions",
38+
"ExperimentOptions",
39+
"SamplingOptions",
40+
)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
import threading
18+
from typing import Optional
19+
20+
import google.auth.credentials
21+
import google.auth.transport.requests
22+
import pydata_google_auth
23+
24+
_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"]
25+
26+
# Put the lock here rather than in BigQueryOptions so that BigQueryOptions
27+
# remains deepcopy-able.
28+
_AUTH_LOCK = threading.Lock()
29+
_cached_credentials: Optional[google.auth.credentials.Credentials] = None
30+
_cached_project_default: Optional[str] = None
31+
32+
33+
def get_default_credentials_with_project() -> (
34+
tuple[google.auth.credentials.Credentials, Optional[str]]
35+
):
36+
global _AUTH_LOCK, _cached_credentials, _cached_project_default
37+
38+
with _AUTH_LOCK:
39+
if _cached_credentials is not None:
40+
return _cached_credentials, _cached_project_default
41+
42+
_cached_credentials, _cached_project_default = pydata_google_auth.default(
43+
scopes=_SCOPES, use_local_webserver=False
44+
)
45+
46+
# Ensure an access token is available.
47+
_cached_credentials.refresh(google.auth.transport.requests.Request())
48+
49+
return _cached_credentials, _cached_project_default
50+
51+
52+
def reset_default_credentials_and_project():
53+
global _AUTH_LOCK, _cached_credentials, _cached_project_default
54+
55+
with _AUTH_LOCK:
56+
_cached_credentials = None
57+
_cached_project_default = None

0 commit comments

Comments
 (0)