Skip to content

Commit

Permalink
fix: drop pkg_resources (#12015)
Browse files Browse the repository at this point in the history
Drop `pkg_resources` in files which are not automatically updated.

`google.cloud.asset_v1p4beta1` is not automatically updated because the
source protos no longer exist here:
https://github.com/googleapis/googleapis-gen/tree/master/google/cloud/asset
. I filed #12016
as a tracking bug to remove the client.

`google.monitoring.dashboard_v1` is not automatically updated because
the client in this location was erroneously created. See tracking issue
#11858

---------

Co-authored-by: ohmayr <omairnaveed@ymail.com>
  • Loading branch information
parthea and ohmayr committed Nov 15, 2023
1 parent d3ae94d commit 7e9cd0c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 57 deletions.
Expand Up @@ -24,7 +24,8 @@
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.asset_v1p4beta1 import gapic_version as package_version

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
Expand Down Expand Up @@ -398,14 +399,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-asset",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("AssetServiceAsyncClient",)
Expand Up @@ -27,7 +27,8 @@
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.asset_v1p4beta1 import gapic_version as package_version

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
Expand Down Expand Up @@ -607,14 +608,9 @@ def __exit__(self, type, value, traceback):
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-asset",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("AssetServiceClient",)
Expand Up @@ -24,18 +24,13 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.asset_v1p4beta1 import gapic_version as package_version
from google.cloud.asset_v1p4beta1.types import asset_service

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-asset",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


class AssetServiceTransport(abc.ABC):
Expand Down
Expand Up @@ -19,17 +19,16 @@
import copy
import logging

import pkg_resources

from google.api_core import exceptions
from google.api_core.gapic_v1 import client_info
import google.cloud.automl_v1beta1
from google.cloud.automl_v1beta1 import AutoMlClient, PredictionServiceClient
from google.cloud.automl_v1beta1 import gapic_version as package_version
from google.cloud.automl_v1beta1.services.tables import gcs_client
from google.cloud.automl_v1beta1.types import data_items
from google.protobuf import struct_pb2

_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-automl").version
_GAPIC_LIBRARY_VERSION = package_version.__version__
_LOGGER = logging.getLogger(__name__)


Expand Down
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -26,8 +26,8 @@
import google.api_core.client_options as ClientOptions # type: ignore
from google.auth import credentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.monitoring.dashboard_v1 import gapic_version as package_version
from google.monitoring.dashboard_v1.services.dashboards_service import pagers
from google.monitoring.dashboard_v1.types import dashboard, dashboards_service, layouts

Expand Down Expand Up @@ -404,14 +404,9 @@ async def update_dashboard(
return response


try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-monitoring-dashboard",
).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("DashboardsServiceAsyncClient",)
Expand Up @@ -28,8 +28,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.auth.transport import mtls # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.monitoring.dashboard_v1 import gapic_version as package_version
from google.monitoring.dashboard_v1.services.dashboards_service import pagers
from google.monitoring.dashboard_v1.types import dashboard, dashboards_service, layouts

Expand Down Expand Up @@ -526,14 +526,9 @@ def update_dashboard(
return response


try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-monitoring-dashboard",
).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("DashboardsServiceClient",)
Expand Up @@ -22,19 +22,14 @@
from google.api_core import gapic_v1 # type: ignore
from google.auth import credentials # type: ignore
from google.protobuf import empty_pb2 as empty # type: ignore
import pkg_resources
from google.monitoring.dashboard_v1 import gapic_version as package_version

from google import auth
from google.monitoring.dashboard_v1.types import dashboard, dashboards_service

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-monitoring-dashboard",
).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


class DashboardsServiceTransport(abc.ABC):
Expand Down

0 comments on commit 7e9cd0c

Please sign in to comment.