-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vertex_rag_source to create_feature_view method
PiperOrigin-RevId: 697000979
- Loading branch information
1 parent
c5121da
commit ca61c5a
Showing
11 changed files
with
260 additions
and
17 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
samples/model-builder/feature_store/create_feature_view_from_rag_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START aiplatform_sdk_create_feature_view_from_rag_source] | ||
|
||
from google.cloud import aiplatform | ||
from vertexai.resources.preview import feature_store | ||
|
||
|
||
def create_feature_view_from_rag_source( | ||
project: str, | ||
location: str, | ||
existing_feature_online_store_id: str, | ||
feature_view_id: str, | ||
bq_table_uri: str, | ||
): | ||
aiplatform.init(project=project, location=location) | ||
fos = feature_store.FeatureOnlineStore(existing_feature_online_store_id) | ||
fv = fos.create_feature_view( | ||
name=feature_view_id, | ||
source=feature_store.utils.FeatureViewVertexRagSource(uri=bq_table_uri), | ||
) | ||
return fv | ||
|
||
|
||
# [END aiplatform_sdk_create_feature_view_from_rag_source] |
39 changes: 39 additions & 0 deletions
39
samples/model-builder/feature_store/create_feature_view_from_rag_source_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from feature_store import create_feature_view_from_rag_source | ||
import test_constants as constants | ||
|
||
|
||
def test_create_feature_view_from_rag_source_sample( | ||
mock_sdk_init, | ||
mock_get_feature_online_store, | ||
): | ||
create_feature_view_from_rag_source.create_feature_view_from_rag_source( | ||
project=constants.PROJECT, | ||
location=constants.LOCATION, | ||
existing_feature_online_store_id=constants.FEATURE_ONLINE_STORE_ID, | ||
feature_view_id=constants.FEATURE_VIEW_ID, | ||
bq_table_uri=constants.FEATURE_VIEW_BQ_URI, | ||
) | ||
|
||
mock_sdk_init.assert_called_once_with( | ||
project=constants.PROJECT, location=constants.LOCATION | ||
) | ||
|
||
mock_get_feature_online_store.assert_called_once() | ||
mock_get_feature_online_store.return_value.create_feature_view.assert_called_once_with( | ||
name=constants.FEATURE_VIEW_ID, | ||
source=constants.FEATURE_VIEW_RAG_SOURCE, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.