diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 563c04b797..29c9decbfb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.27.0" + ".": "1.27.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf633b03a..1f103d33fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog +## [1.27.1](https://github.com/googleapis/python-aiplatform/compare/v1.27.0...v1.27.1) (2023-07-06) + + +### Features + +* Add sdk support for xai example-based explanations ([f9ca1d5](https://github.com/googleapis/python-aiplatform/commit/f9ca1d52a6789f93b4eca9596c04f52a2ca75513)) + + +### Miscellaneous Chores + +* Release 1.27.1 ([2159f29](https://github.com/googleapis/python-aiplatform/commit/2159f29e8322aef33cfa27df52a57f7cc7722868)) + ## [1.27.0](https://github.com/googleapis/python-aiplatform/compare/v1.26.1...v1.27.0) (2023-06-30) diff --git a/google/cloud/aiplatform/explain/__init__.py b/google/cloud/aiplatform/explain/__init__.py index 8167e80a4a..ec7f15f003 100644 --- a/google/cloud/aiplatform/explain/__init__.py +++ b/google/cloud/aiplatform/explain/__init__.py @@ -42,6 +42,8 @@ SampledShapleyAttribution = explanation_compat.SampledShapleyAttribution SmoothGradConfig = explanation_compat.SmoothGradConfig XraiAttribution = explanation_compat.XraiAttribution +Presets = explanation_compat.Presets +Examples = explanation_compat.Examples __all__ = ( @@ -58,4 +60,6 @@ "SmoothGradConfig", "Visualization", "XraiAttribution", + "Presets", + "Examples", ) diff --git a/google/cloud/aiplatform/gapic_version.py b/google/cloud/aiplatform/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/gapic_version.py +++ b/google/cloud/aiplatform/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/releases.txt b/google/cloud/aiplatform/releases.txt index a6a52c9d4f..9794dd7c95 100644 --- a/google/cloud/aiplatform/releases.txt +++ b/google/cloud/aiplatform/releases.txt @@ -1,4 +1,4 @@ Use this file when you need to force a patch release with release-please. Edit line 4 below with the version for the release. -1.26.1 \ No newline at end of file +1.27.1 \ No newline at end of file diff --git a/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform/version.py b/google/cloud/aiplatform/version.py index b8b9fff801..fe91482864 100644 --- a/google/cloud/aiplatform/version.py +++ b/google/cloud/aiplatform/version.py @@ -15,4 +15,4 @@ # limitations under the License. # -__version__ = "1.27.0" +__version__ = "1.27.1" diff --git a/google/cloud/aiplatform_v1/gapic_version.py b/google/cloud/aiplatform_v1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform_v1/gapic_version.py +++ b/google/cloud/aiplatform_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/google/cloud/aiplatform_v1beta1/gapic_version.py b/google/cloud/aiplatform_v1beta1/gapic_version.py index 26ab66b2e5..56b00073f9 100644 --- a/google/cloud/aiplatform_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.27.0" # {x-release-please-version} +__version__ = "1.27.1" # {x-release-please-version} diff --git a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json index a768913d9d..f8c89df552 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-aiplatform", - "version": "1.27.0" + "version": "1.27.1" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json index 2bb2c635e1..da298c0c02 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-aiplatform", - "version": "1.27.0" + "version": "1.27.1" }, "snippets": [ { diff --git a/tests/unit/aiplatform/test_models.py b/tests/unit/aiplatform/test_models.py index e444070c98..842ab70b5c 100644 --- a/tests/unit/aiplatform/test_models.py +++ b/tests/unit/aiplatform/test_models.py @@ -152,6 +152,59 @@ _TEST_EXPLANATION_PARAMETERS = ( test_constants.ModelConstants._TEST_EXPLANATION_PARAMETERS ) +_TEST_EXPLANATION_METADATA_EXAMPLES = explain.ExplanationMetadata( + outputs={"embedding": {"output_tensor_name": "embedding"}}, + inputs={ + "my_input": { + "input_tensor_name": "bytes_inputs", + "encoding": "IDENTITY", + "modality": "image", + }, + "id": {"input_tensor_name": "id", "encoding": "IDENTITY"}, + }, +) +_TEST_EXPLANATION_PARAMETERS_EXAMPLES_PRESETS = explain.ExplanationParameters( + { + "examples": { + "example_gcs_source": { + "gcs_source": { + "uris": ["gs://example-bucket/folder/instance1.jsonl"], + }, + }, + "neighbor_count": 10, + "presets": {"query": "FAST", "modality": "TEXT"}, + } + } +) +_TEST_EXPLANATION_PARAMETERS_EXAMPLES_FULL_CONFIG = explain.ExplanationParameters( + { + "examples": { + "example_gcs_source": { + "gcs_source": { + "uris": ["gs://example-bucket/folder/instance1.jsonl"], + }, + }, + "neighbor_count": 10, + "nearest_neighbor_search_config": [ + { + "contentsDeltaUri": "", + "config": { + "dimensions": 50, + "approximateNeighborsCount": 10, + "distanceMeasureType": "SQUARED_L2_DISTANCE", + "featureNormType": "NONE", + "algorithmConfig": { + "treeAhConfig": { + "leafNodeEmbeddingCount": 1000, + "leafNodesToSearchPercent": 100, + } + }, + }, + } + ], + } + } +) # CMEK encryption _TEST_ENCRYPTION_KEY_NAME = "key_1234" @@ -1119,6 +1172,80 @@ def test_upload_with_parameters_without_metadata( timeout=None, ) + @pytest.mark.parametrize("sync", [True, False]) + def test_upload_with_parameters_for_examples_presets( + self, upload_model_mock, get_model_mock, sync + ): + my_model = models.Model.upload( + display_name=_TEST_MODEL_NAME, + serving_container_image_uri=_TEST_SERVING_CONTAINER_IMAGE, + explanation_parameters=_TEST_EXPLANATION_PARAMETERS_EXAMPLES_PRESETS, + explanation_metadata=_TEST_EXPLANATION_METADATA_EXAMPLES, + sync=sync, + ) + + if not sync: + my_model.wait() + + container_spec = gca_model.ModelContainerSpec( + image_uri=_TEST_SERVING_CONTAINER_IMAGE, + ) + + managed_model = gca_model.Model( + display_name=_TEST_MODEL_NAME, + container_spec=container_spec, + explanation_spec=gca_model.explanation.ExplanationSpec( + metadata=_TEST_EXPLANATION_METADATA_EXAMPLES, + parameters=_TEST_EXPLANATION_PARAMETERS_EXAMPLES_PRESETS, + ), + version_aliases=["default"], + ) + + upload_model_mock.assert_called_once_with( + request=gca_model_service.UploadModelRequest( + parent=initializer.global_config.common_location_path(), + model=managed_model, + ), + timeout=None, + ) + + @pytest.mark.parametrize("sync", [True, False]) + def test_upload_with_parameters_for_examples_full_config( + self, upload_model_mock, get_model_mock, sync + ): + my_model = models.Model.upload( + display_name=_TEST_MODEL_NAME, + serving_container_image_uri=_TEST_SERVING_CONTAINER_IMAGE, + explanation_parameters=_TEST_EXPLANATION_PARAMETERS_EXAMPLES_FULL_CONFIG, + explanation_metadata=_TEST_EXPLANATION_METADATA_EXAMPLES, + sync=sync, + ) + + if not sync: + my_model.wait() + + container_spec = gca_model.ModelContainerSpec( + image_uri=_TEST_SERVING_CONTAINER_IMAGE, + ) + + managed_model = gca_model.Model( + display_name=_TEST_MODEL_NAME, + container_spec=container_spec, + explanation_spec=gca_model.explanation.ExplanationSpec( + metadata=_TEST_EXPLANATION_METADATA_EXAMPLES, + parameters=_TEST_EXPLANATION_PARAMETERS_EXAMPLES_FULL_CONFIG, + ), + version_aliases=["default"], + ) + + upload_model_mock.assert_called_once_with( + request=gca_model_service.UploadModelRequest( + parent=initializer.global_config.common_location_path(), + model=managed_model, + ), + timeout=None, + ) + @pytest.mark.parametrize("sync", [True, False]) def test_upload_uploads_and_gets_model_with_all_args( self, upload_model_mock, get_model_mock, sync