diff --git a/tests/unit/vertexai/test_vertexai_feature.py b/tests/unit/vertexai/test_vertexai_feature.py index 6da9e3b4fb..8a6578cb6d 100644 --- a/tests/unit/vertexai/test_vertexai_feature.py +++ b/tests/unit/vertexai/test_vertexai_feature.py @@ -157,6 +157,25 @@ def test_init_with_feature_id(get_feature_mock): ) +def test_init_with_feature_id_uses_the_given_project_and_location(get_feature_mock): + aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION) + + Feature( + name=_TEST_FG1_F1_ID, + feature_group_id=_TEST_FG1_ID, + project="other-project", + location="europe-west4", + ) + + get_feature_mock.assert_called_once_with( + name=( + "projects/other-project/locations/europe-west4/" + f"featureGroups/{_TEST_FG1_ID}/features/{_TEST_FG1_F1_ID}" + ), + retry=base._DEFAULT_RETRY, + ) + + def test_init_with_feature_id_for_explicit_version_column( get_feature_with_version_column_mock, ): diff --git a/tests/unit/vertexai/test_vertexai_feature_monitor.py b/tests/unit/vertexai/test_vertexai_feature_monitor.py index f6934b7e13..826229d73f 100644 --- a/tests/unit/vertexai/test_vertexai_feature_monitor.py +++ b/tests/unit/vertexai/test_vertexai_feature_monitor.py @@ -181,6 +181,27 @@ def test_init_with_feature_monitor_path_and_fg_id_raises_error(): ) +def test_init_with_feature_monitor_id_uses_the_given_project_and_location( + get_feature_monitor_mock, +): + aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION) + + FeatureMonitor( + _TEST_FG1_FM1_ID, + feature_group_id=_TEST_FG1_ID, + project="other-project", + location="europe-west4", + ) + + get_feature_monitor_mock.assert_called_once_with( + name=( + "projects/other-project/locations/europe-west4/" + f"featureGroups/{_TEST_FG1_ID}/featureMonitors/{_TEST_FG1_FM1_ID}" + ), + retry=base._DEFAULT_RETRY, + ) + + def test_init_with_feature_monitor_id(get_feature_monitor_mock): aiplatform.init( project=_TEST_PROJECT, diff --git a/tests/unit/vertexai/test_vertexai_feature_view.py b/tests/unit/vertexai/test_vertexai_feature_view.py index 5fbd17f8ba..3eead2f44d 100644 --- a/tests/unit/vertexai/test_vertexai_feature_view.py +++ b/tests/unit/vertexai/test_vertexai_feature_view.py @@ -221,6 +221,25 @@ def test_init_with_fv_id_and_no_fos_id_raises_error(get_fv_mock): FeatureView(_TEST_FV1_ID) +def test_init_with_fv_id_uses_the_given_project_and_location(get_fv_mock): + aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION) + + FeatureView( + name=_TEST_FV1_ID, + feature_online_store_id=_TEST_BIGTABLE_FOS1_ID, + project="other-project", + location="europe-west4", + ) + + get_fv_mock.assert_called_once_with( + name=( + "projects/other-project/locations/europe-west4/" + f"featureOnlineStores/{_TEST_BIGTABLE_FOS1_ID}/featureViews/{_TEST_FV1_ID}" + ), + retry=base._DEFAULT_RETRY, + ) + + def test_init_with_fv_id(get_fv_mock): aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION) diff --git a/vertexai/resources/preview/feature_store/feature.py b/vertexai/resources/preview/feature_store/feature.py index 625df73377..062cd88d3d 100644 --- a/vertexai/resources/preview/feature_store/feature.py +++ b/vertexai/resources/preview/feature_store/feature.py @@ -105,6 +105,8 @@ def __init__( resource_noun=FeatureGroup._resource_noun, parse_resource_name_method=FeatureGroup._parse_resource_name, format_resource_name_method=FeatureGroup._format_resource_name, + project=project, + location=location, ) feature = f"{feature_group_path}/features/{name}" diff --git a/vertexai/resources/preview/feature_store/feature_monitor.py b/vertexai/resources/preview/feature_store/feature_monitor.py index c5f6ac7276..09601635ce 100644 --- a/vertexai/resources/preview/feature_store/feature_monitor.py +++ b/vertexai/resources/preview/feature_store/feature_monitor.py @@ -101,6 +101,8 @@ def __init__( resource_noun=FeatureGroup._resource_noun, parse_resource_name_method=FeatureGroup._parse_resource_name, format_resource_name_method=FeatureGroup._format_resource_name, + project=project, + location=location, ) feature_monitor = f"{feature_group_path}/featureMonitors/{name}" diff --git a/vertexai/resources/preview/feature_store/feature_view.py b/vertexai/resources/preview/feature_store/feature_view.py index 8031dead05..6556cdf88d 100644 --- a/vertexai/resources/preview/feature_store/feature_view.py +++ b/vertexai/resources/preview/feature_store/feature_view.py @@ -106,6 +106,8 @@ def __init__( resource_noun=FeatureOnlineStore._resource_noun, parse_resource_name_method=FeatureOnlineStore._parse_resource_name, format_resource_name_method=FeatureOnlineStore._format_resource_name, + project=project, + location=location, ) feature_view = f"{feature_online_store_path}/featureViews/{name}"