Skip to content

Commit

Permalink
Copybara import of the project:
Browse files Browse the repository at this point in the history
--
b230f56 by Kevin James <KevinJames@thekev.in>:

refactor: migrate off pkg_resources

pkg_resources has been deprecated in favour of the builtin `importlib.*`
packages. Note that for python3.7 support, we need the
`importlib-metadata` backport library; once that version is dropped, the
conditional dependency pin and imports can be removed.

See the PyPA docs[1] for more info.

1: https://setuptools.pypa.io/en/latest/pkg_resources.html

--
b6b6d0b by Kevin James <KevinJames@thekev.in>:

chore: respond to pr review
COPYBARA_INTEGRATE_REVIEW=#3298 from TheKevJames:kjames/nuke-pkg-resources b6b6d0b
PiperOrigin-RevId: 606318888
  • Loading branch information
TheKevJames authored and copybara-github committed Feb 12, 2024
1 parent 35e57b3 commit 32c7197
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
5 changes: 0 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
6 changes: 2 additions & 4 deletions google/cloud/aiplatform/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from concurrent import futures
import inspect
import logging
import pkg_resources # noqa: F401 # Note this is used after copybara replacement
import os
import types
from typing import Iterator, List, Optional, Type, TypeVar, Union
Expand All @@ -30,6 +29,7 @@
from google.auth import credentials as auth_credentials
from google.auth.exceptions import GoogleAuthError

from google.cloud.aiplatform import __version__
from google.cloud.aiplatform import compat
from google.cloud.aiplatform.constants import base as constants
from google.cloud.aiplatform import utils
Expand Down Expand Up @@ -447,9 +447,7 @@ def create_client(
Returns:
client: Instantiated Vertex AI Service client with optional overrides
"""
gapic_version = pkg_resources.get_distribution(
"google-cloud-aiplatform",
).version
gapic_version = __version__

if appended_gapic_version:
gapic_version = f"{gapic_version}+{appended_gapic_version}"
Expand Down
6 changes: 2 additions & 4 deletions tests/system/aiplatform/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
import importlib

import pandas as pd
import pkg_resources
import re

from datetime import datetime

from google.api_core import exceptions
from google.api_core import client_options

from google.cloud import bigquery

from google.cloud import aiplatform
from google.cloud import bigquery
from google.cloud import storage
from google.cloud.aiplatform import utils
from google.cloud.aiplatform import initializer
Expand Down Expand Up @@ -302,7 +300,7 @@ def test_create_tabular_dataset_from_dataframe(self, bigquery_dataset):
== bigquery.SchemaField(name="datetime_col", field_type="DATETIME")
if re.match(
r"3.*",
pkg_resources.get_distribution("google-cloud-bigquery").version,
bigquery.__version__,
)
else bigquery.SchemaField(name="datetime_col", field_type="TIMESTAMP")
)
Expand Down

0 comments on commit 32c7197

Please sign in to comment.