Skip to content

Commit 13442f8

Browse files
yinghsienwucopybara-github
authored andcommitted
chore: fix Ray client logging and internal clean up
FUTURE_COPYBARA_INTEGRATE_REVIEW=#2604 from googleapis:release-please--branches--main a84695c PiperOrigin-RevId: 567439389
1 parent afd0461 commit 13442f8

5 files changed

Lines changed: 26 additions & 19 deletions

File tree

google/cloud/aiplatform/constants/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
import os
17+
1818
from google.cloud.aiplatform import version as aiplatform_version
1919

2020

@@ -56,8 +56,8 @@
5656
"us-west4",
5757
}
5858
)
59-
# This env variable injection is for testing, but not considered to be a public API.
60-
API_BASE_PATH = os.environ.get("_VERTEX_API_BASE_PATH") or "aiplatform.googleapis.com"
59+
60+
API_BASE_PATH = "aiplatform.googleapis.com"
6161
PREDICTION_API_BASE_PATH = API_BASE_PATH
6262

6363
# Batch Prediction

google/cloud/aiplatform/initializer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,13 @@ def create_client(
421421
"google-cloud-aiplatform",
422422
).version
423423

424+
if appended_gapic_version:
425+
gapic_version = f"{gapic_version}+{appended_gapic_version}"
426+
424427
user_agent = f"{constants.USER_AGENT_PRODUCT}/{gapic_version}"
425428
if appended_user_agent:
426429
user_agent = f"{user_agent} {' '.join(appended_user_agent)}"
427430

428-
if appended_gapic_version:
429-
gapic_version = f"{gapic_version}+{appended_gapic_version}"
430-
431431
client_info = gapic_v1.client_info.ClientInfo(
432432
gapic_version=gapic_version,
433433
user_agent=user_agent,

google/cloud/aiplatform/preview/vertex_ray/client_builder.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
17+
import logging
1818
from typing import Dict
1919
from typing import Optional
2020
from google.cloud import aiplatform
21-
from google.cloud.aiplatform import base
2221
from ray import client_builder
2322
from .render import VertexRayTemplate
2423
from .util import _validation_utils
2524
from .util import _gapic_utils
2625

2726

2827
VERTEX_SDK_VERSION = aiplatform.__version__
29-
_LOGGER = base.Logger(__name__)
3028

3129

3230
class _VertexRayClientContext(client_builder.ClientContext):
@@ -84,7 +82,7 @@ def __init__(self, address: Optional[str]) -> None:
8482
_validation_utils.valid_resource_name(address)
8583

8684
self.vertex_address = address
87-
_LOGGER.info(
85+
print(
8886
"[Ray on Vertex AI]: Using cluster resource name to access head address with GAPIC API"
8987
)
9088

@@ -112,12 +110,12 @@ def __init__(self, address: Optional[str]) -> None:
112110
address,
113111
" failed to start Head node properly because custom service account isn't supported.",
114112
)
115-
_LOGGER.debug("[Ray on Vertex AI]: Resolved head node ip: %s", address)
113+
logging.debug("[Ray on Vertex AI]: Resolved head node ip: %s", address)
116114
super().__init__(address)
117115

118116
def connect(self) -> _VertexRayClientContext:
119117
# Can send any other params to ray cluster here
120-
_LOGGER.info("[Ray on Vertex AI]: Connecting...")
118+
print("[Ray on Vertex AI]: Connecting...")
121119
ray_client_context = super().connect()
122120
ray_head_uris = self.response.resource_runtime.access_uris
123121

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
]
7575

7676
vizier_extra_require = [
77-
"google-vizier==0.0.4; python_version<'3.11'",
77+
"google-vizier==0.0.11; python_version>='3.9', '<'3.11'",
7878
"google-vizier>=0.1.6; python_version>='3.11'",
7979
]
8080

tests/unit/aiplatform/test_explain_lit.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,30 @@
2929
prediction_service as gca_prediction_service,
3030
explanation as gca_explanation,
3131
)
32-
from google.cloud.aiplatform.explain.lit import (
32+
33+
# TODO (b/301592787): update testing_extra_require deps to numpy >= 1.22.0 when it doesn't cause conflicts
34+
try:
35+
from lit_nlp import notebook # noqa: F401
36+
except ImportError:
37+
pytest.skip(
38+
"Skipping test_explain_list due to dependency conflict with numpy",
39+
allow_module_level=True,
40+
)
41+
42+
from google.cloud.aiplatform.explain.lit import ( # noqa: E402
3343
create_lit_dataset,
3444
create_lit_model,
3545
create_lit_model_from_endpoint,
3646
open_lit,
3747
set_up_and_open_lit,
3848
)
39-
from google.cloud.aiplatform.compat.services import (
49+
from google.cloud.aiplatform.compat.services import ( # noqa: E402
4050
endpoint_service_client,
4151
prediction_service_client,
4252
)
43-
from importlib import reload
44-
from lit_nlp.api import types as lit_types
45-
from lit_nlp import notebook
46-
from unittest import mock
53+
from importlib import reload # noqa: E402
54+
from lit_nlp.api import types as lit_types # noqa: E402
55+
from unittest import mock # noqa: E402
4756

4857
_TEST_PROJECT = "test-project"
4958
_TEST_LOCATION = "us-central1"

0 commit comments

Comments
 (0)