-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(samples): added create feature and create entity type samples an…
…d tests (#984) * feat: SDK feature store samples (create/delete fs) * feat: adding to conftest.py * docs(samples): fixed testing * docs(samples): fixed testing * docs(samples): fixed testing * docs(samples) added changes * docs(samples): style issues * adding create entity * docs(samples): added create feature and entity type * docs(samples): edited test * docs(samples) edited style * moving constants * fixed dates * Update samples/model-builder/create_featurestore_sample_test.py Co-authored-by: Morgan Du <[email protected]> * Update samples/model-builder/test_constants.py Co-authored-by: Morgan Du <[email protected]> * Update samples/model-builder/create_featurestore_sample_test.py Co-authored-by: Morgan Du <[email protected]> * docs(samples): add samples to create/delete featurestore (#980) * feat: SDK feature store samples (create/delete fs) * feat: adding to conftest.py * docs(samples): fixed testing * docs(samples): fixed testing * docs(samples): fixed testing * docs(samples) added changes * docs(samples): style issues * Update samples/model-builder/create_featurestore_sample_test.py Co-authored-by: Morgan Du <[email protected]> * Update samples/model-builder/test_constants.py Co-authored-by: Morgan Du <[email protected]> * Update samples/model-builder/create_featurestore_sample_test.py Co-authored-by: Morgan Du <[email protected]> Co-authored-by: Morgan Du <[email protected]> * Update samples/model-builder/test_constants.py Co-authored-by: Morgan Du <[email protected]> * moving constants * added variables, made fixes, fixed spelling Co-authored-by: Morgan Du <[email protected]>
- Loading branch information
1 parent
5fe59a4
commit d221e6b
Showing
8 changed files
with
193 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2022 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_entity_type_sample] | ||
from google.cloud import aiplatform | ||
|
||
|
||
def create_entity_type_sample( | ||
project: str, location: str, entity_type_id: str, featurestore_name: str, | ||
): | ||
|
||
aiplatform.init(project=project, location=location) | ||
|
||
my_entity_type = aiplatform.EntityType.create( | ||
entity_type_id=entity_type_id, featurestore_name=featurestore_name | ||
) | ||
|
||
my_entity_type.wait() | ||
|
||
return my_entity_type | ||
|
||
|
||
# [END aiplatform_sdk_create_entity_type_sample] |
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,35 @@ | ||
# Copyright 2022 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. | ||
|
||
import create_entity_type_sample | ||
import test_constants as constants | ||
|
||
|
||
def test_create_entity_type_sample(mock_sdk_init, mock_create_entity_type): | ||
|
||
create_entity_type_sample.create_entity_type_sample( | ||
project=constants.PROJECT, | ||
location=constants.LOCATION, | ||
entity_type_id=constants.ENTITY_TYPE_ID, | ||
featurestore_name=constants.FEATURESTORE_NAME, | ||
) | ||
|
||
mock_sdk_init.assert_called_once_with( | ||
project=constants.PROJECT, location=constants.LOCATION | ||
) | ||
|
||
mock_create_entity_type.assert_called_once_with( | ||
entity_type_id=constants.ENTITY_TYPE_ID, | ||
featurestore_name=constants.FEATURESTORE_NAME, | ||
) |
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,43 @@ | ||
# Copyright 2022 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_sample] | ||
from google.cloud import aiplatform | ||
|
||
|
||
def create_feature_sample( | ||
project: str, | ||
location: str, | ||
feature_id: str, | ||
value_type: str, | ||
entity_type_id: str, | ||
featurestore_id: str, | ||
): | ||
|
||
aiplatform.init(project=project, location=location) | ||
|
||
my_feature = aiplatform.Feature.create( | ||
feature_id=feature_id, | ||
value_type=value_type, | ||
entity_type_name=entity_type_id, | ||
featurestore_id=featurestore_id, | ||
) | ||
|
||
my_feature.wait() | ||
|
||
return my_feature | ||
|
||
|
||
# [END aiplatform_sdk_create_feature_sample] |
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 2022 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. | ||
|
||
import create_feature_sample | ||
import test_constants as constants | ||
|
||
|
||
def test_create_feature_sample(mock_sdk_init, mock_create_feature): | ||
|
||
create_feature_sample.create_feature_sample( | ||
project=constants.PROJECT, | ||
location=constants.LOCATION, | ||
feature_id=constants.FEATURE_ID, | ||
value_type=constants.FEATURE_VALUE_TYPE, | ||
entity_type_id=constants.ENTITY_TYPE_ID, | ||
featurestore_id=constants.FEATURESTORE_ID, | ||
) | ||
|
||
mock_sdk_init.assert_called_once_with( | ||
project=constants.PROJECT, location=constants.LOCATION | ||
) | ||
|
||
mock_create_feature.assert_called_once_with( | ||
feature_id=constants.FEATURE_ID, | ||
value_type=constants.FEATURE_VALUE_TYPE, | ||
entity_type_name=constants.ENTITY_TYPE_ID, | ||
featurestore_id=constants.FEATURESTORE_ID, | ||
) |
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