Skip to content

Commit f40f322

Browse files
authored
fix: use resource name location when passed full resource name (#421)
1 parent 2abca93 commit f40f322

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

google/cloud/aiplatform/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,6 @@ def _get_and_validate_project_location(
501501
RuntimeError if location is different from resource location
502502
"""
503503

504-
if not project and not location:
505-
return project, location
506-
507504
fields = utils.extract_fields_from_resource_name(
508505
resource_name, self._resource_noun
509506
)

tests/unit/aiplatform/test_datasets.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from google.cloud import bigquery
3232
from google.cloud import storage
3333

34+
from google.cloud.aiplatform import compat
3435
from google.cloud.aiplatform import datasets
3536
from google.cloud.aiplatform import initializer
3637
from google.cloud.aiplatform import schema
@@ -401,6 +402,20 @@ def test_init_dataset_with_alt_project_and_location(self, get_dataset_mock):
401402
)
402403
get_dataset_mock.assert_called_once_with(name=_TEST_NAME)
403404

405+
def test_init_dataset_with_alt_location(self, get_dataset_tabular_gcs_mock):
406+
aiplatform.init(project=_TEST_PROJECT, location=_TEST_ALT_LOCATION)
407+
408+
ds = datasets.TabularDataset(dataset_name=_TEST_NAME)
409+
410+
assert (
411+
ds.api_client._clients[compat.DEFAULT_VERSION]._client_options.api_endpoint
412+
== f"{_TEST_LOCATION}-{aiplatform.constants.API_BASE_PATH}"
413+
)
414+
415+
assert _TEST_ALT_LOCATION != _TEST_LOCATION
416+
417+
get_dataset_tabular_gcs_mock.assert_called_once_with(name=_TEST_NAME)
418+
404419
def test_init_dataset_with_project_and_alt_location(self):
405420
aiplatform.init(project=_TEST_PROJECT)
406421
with pytest.raises(RuntimeError):

0 commit comments

Comments
 (0)