Skip to content

Commit

Permalink
chore: fix attribute errors on external packages when importing SDK
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 576296610
  • Loading branch information
jaycee-li authored and copybara-github committed Oct 24, 2023
1 parent 3d43497 commit 8e42bc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions google/cloud/aiplatform/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import tempfile
import uuid

from google.cloud import storage
from google.cloud import bigquery

from google.auth import credentials as auth_credentials
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
Expand Down Expand Up @@ -892,7 +889,9 @@ def _create(

def iter_outputs(
self, bq_max_results: Optional[int] = 100
) -> Union[Iterable[storage.Blob], Iterable[bigquery.table.RowIterator]]:
) -> Union[
Iterable["storage.Blob"], Iterable["bigquery.table.RowIterator"] # noqa: F821
]:
"""Returns an Iterable object to traverse the output files, either a
list of GCS Blobs or a BigQuery RowIterator depending on the output
config set when the BatchPredictionJob was created.
Expand All @@ -916,6 +915,9 @@ def iter_outputs(
If BatchPredictionJob succeeded and output_info does not have a
GCS or BQ output provided.
"""
# pylint: disable=g-import-not-at-top
from google.cloud import bigquery
from google.cloud import storage

self._assert_gca_resource_is_available()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
import sklearn

SklearnEstimator = sklearn.base.BaseEstimator
except ImportError:
# Temp fix for sklearn version too old and doesn't have `base` attribute
# TODO(b/307540407) Lazy import on external pckages
except (ImportError, AttributeError):
sklearn = None
SklearnEstimator = Any

Expand Down

0 comments on commit 8e42bc5

Please sign in to comment.