Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 300d1ba

Browse files
committed
moved classic client into its own subdirectory
1 parent d9626a8 commit 300d1ba

20 files changed

Lines changed: 106 additions & 48 deletions

google/cloud/bigtable/__init__.py

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,58 @@
1-
# Copyright 2015 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.
1+
import importlib
2+
import sys
3+
import warnings
144

15-
"""Google Cloud Bigtable API package."""
165

17-
from google.cloud.bigtable.client import Client
6+
_LEGACY_MODULE_NAMES = {
7+
"app_profile",
8+
"backup",
9+
"batcher",
10+
"client",
11+
"cluster",
12+
"column_family",
13+
"encryption_info",
14+
"enums",
15+
"error",
16+
"helpers",
17+
"instance",
18+
"policy",
19+
"row_data",
20+
"row_filters",
21+
"row_merger",
22+
"row_set",
23+
"row",
24+
"table",
25+
}
1826

19-
from google.cloud.bigtable import gapic_version as package_version
27+
# Eagerly create aliases in sys.modules for full backward compatibility.
28+
# This is more robust than the lazy __getattr__ approach because it handles
29+
# direct submodule imports (e.g., `import google.cloud.bigtable.row_data`).
30+
for module_name in _LEGACY_MODULE_NAMES:
31+
# Define the old and new module paths
32+
old_path = f"google.cloud.bigtable.{module_name}"
33+
new_path = f".classic.{module_name}"
2034

21-
__version__: str
35+
# Import the module from its new location
36+
module = importlib.import_module(new_path, __name__)
2237

23-
__version__ = package_version.__version__
38+
# Inject the loaded module into sys.modules under its old path.
39+
# This makes Python's import machinery find it automatically.
40+
sys.modules[old_path] = module
2441

25-
__all__ = ["__version__", "Client"]
42+
# Attach the module as an attribute to the current package
43+
setattr(sys.modules[__name__], module_name, module)
44+
45+
# You can also issue a single, general warning that some modules were moved.
46+
warnings.warn(
47+
(
48+
"Several modules have been moved to the `google.cloud.bigtable.classic` "
49+
"subpackage. The top-level aliases will be removed in a future version."
50+
),
51+
DeprecationWarning,
52+
stacklevel=2,
53+
)
54+
55+
# previously exported classes
56+
from google.cloud.bigtable.classic.client import Client
57+
from . import gapic_version
58+
__version__ = gapic_version.__version__
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2015 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+
"""Google Cloud Bigtable API package."""
16+
17+
from .client import Client
18+
19+
from google.cloud.bigtable import gapic_version as package_version
20+
21+
__version__: str
22+
23+
__version__ = package_version.__version__
24+
25+
__all__ = ["__version__", "Client"]

google/cloud/bigtable/app_profile.py renamed to google/cloud/bigtable/classic/app_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import re
1919

20-
from google.cloud.bigtable.enums import RoutingPolicyType
20+
from .enums import RoutingPolicyType
2121
from google.cloud.bigtable_admin_v2.types import instance
2222
from google.protobuf import field_mask_pb2
2323
from google.api_core.exceptions import NotFound
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
2020
from google.cloud.bigtable_admin_v2 import BigtableTableAdminClient
2121
from google.cloud.bigtable_admin_v2.types import table
22-
from google.cloud.bigtable.encryption_info import EncryptionInfo
23-
from google.cloud.bigtable.policy import Policy
22+
from .encryption_info import EncryptionInfo
23+
from .policy import Policy
2424
from google.cloud.exceptions import NotFound # type: ignore
2525
from google.protobuf import field_mask_pb2
2626

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
)
4646

4747
from google.cloud import bigtable
48-
from google.cloud.bigtable.instance import Instance
49-
from google.cloud.bigtable.cluster import Cluster
48+
from .instance import Instance
49+
from .cluster import Cluster
5050

5151
from google.cloud.client import ClientWithProject # type: ignore
5252

5353
from google.cloud.bigtable_admin_v2.types import instance
54-
from google.cloud.bigtable.cluster import _CLUSTER_NAME_RE
54+
from .cluster import _CLUSTER_NAME_RE
5555
from google.cloud.environment_vars import BIGTABLE_EMULATOR # type: ignore
5656

5757

File renamed without changes.

google/cloud/bigtable/encryption_info.py renamed to google/cloud/bigtable/classic/encryption_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"""Class for encryption info for tables and backups."""
1616

17-
from google.cloud.bigtable.error import Status
17+
from .error import Status
1818

1919

2020
class EncryptionInfo:

0 commit comments

Comments
 (0)