diff --git a/.sample_configs/param_handlers/export_model_sample.py b/.sample_configs/param_handlers/export_model_sample.py index c096b20d45..0e2b096659 100644 --- a/.sample_configs/param_handlers/export_model_sample.py +++ b/.sample_configs/param_handlers/export_model_sample.py @@ -23,7 +23,9 @@ def make_output_config(gcs_destination_output_uri_prefix: str) -> google.cloud.a output_config = { 'artifact_destination': { 'output_uri_prefix': gcs_destination_output_uri_prefix - } + }, + # For information about export formats: https://cloud.google.com/ai-platform-unified/docs/export/export-edge-model#aiplatform_export_model_sample-drest + 'export_format_id': 'tf-saved-model' } return output_config diff --git a/CHANGELOG.md b/CHANGELOG.md index 315d5a8da1..ea9ca7a7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +### [0.5.1](https://www.github.com/googleapis/python-aiplatform/compare/v0.5.0...v0.5.1) (2021-03-01) + + +### Bug Fixes + +* fix create data labeling job samples tests ([#244](https://www.github.com/googleapis/python-aiplatform/issues/244)) ([3c440de](https://www.github.com/googleapis/python-aiplatform/commit/3c440dea14ad4d04b05ebf17ba4bcb031fe95b3e)) +* fix predict sample tests for proto-plus==1.14.2 ([#250](https://www.github.com/googleapis/python-aiplatform/issues/250)) ([b1c9d88](https://www.github.com/googleapis/python-aiplatform/commit/b1c9d88646f00b034e2576890406325db5384f10)) +* fix update export model sample, and add sample test ([#239](https://www.github.com/googleapis/python-aiplatform/issues/239)) ([20b8859](https://www.github.com/googleapis/python-aiplatform/commit/20b88592da3dd7344c7053d7fe652115ed42e4aa)) + + +### Documentation + +* update index.rst to include v1 ([#246](https://www.github.com/googleapis/python-aiplatform/issues/246)) ([82193ef](https://www.github.com/googleapis/python-aiplatform/commit/82193ef401258b17fd20895e2b0f6c95a39a24a1)) + ## [0.5.0](https://www.github.com/googleapis/python-aiplatform/compare/v0.4.0...v0.5.0) (2021-02-17) diff --git a/docs/index.rst b/docs/index.rst index 281df0bdf7..765eb55989 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,6 +7,9 @@ API Reference .. toctree:: :maxdepth: 2 + aiplatform_v1/services + aiplatform_v1/types + aiplatform_v1beta1/services aiplatform_v1beta1/types diff --git a/google/cloud/aiplatform/__init__.py b/google/cloud/aiplatform/__init__.py index cc378079ab..bb196e2c19 100644 --- a/google/cloud/aiplatform/__init__.py +++ b/google/cloud/aiplatform/__init__.py @@ -18,4 +18,4 @@ from google.cloud.aiplatform import gapic -__all__ = (gapic,) +__all__ = ("gapic",) diff --git a/samples/snippets/conftest.py b/samples/snippets/conftest.py index d40fcf987d..2d2dd2fa78 100644 --- a/samples/snippets/conftest.py +++ b/samples/snippets/conftest.py @@ -117,7 +117,6 @@ def teardown_data_labeling_job(capsys, shared_state, data_labeling_job_client): helpers.wait_for_job_state( get_job_method=data_labeling_job_client.get_data_labeling_job, name=shared_state["data_labeling_job_name"], - expected_state='FAILED', timeout=400, freq=10, ) diff --git a/samples/snippets/export_model_sample.py b/samples/snippets/export_model_sample.py index ab066e99ed..86b7755e50 100644 --- a/samples/snippets/export_model_sample.py +++ b/samples/snippets/export_model_sample.py @@ -30,7 +30,11 @@ def export_model_sample( # This client only needs to be created once, and can be reused for multiple requests. client = aiplatform.gapic.ModelServiceClient(client_options=client_options) output_config = { - "artifact_destination": {"output_uri_prefix": gcs_destination_output_uri_prefix} + "artifact_destination": { + "output_uri_prefix": gcs_destination_output_uri_prefix + }, + # For information about export formats: https://cloud.google.com/ai-platform-unified/docs/export/export-edge-model#aiplatform_export_model_sample-drest + "export_format_id": "tf-saved-model", } name = client.model_path(project=project, location=location, model=model_id) response = client.export_model(name=name, output_config=output_config) diff --git a/samples/snippets/export_model_sample_test.py b/samples/snippets/export_model_sample_test.py new file mode 100644 index 0000000000..67a625b657 --- /dev/null +++ b/samples/snippets/export_model_sample_test.py @@ -0,0 +1,47 @@ +# Copyright 2020 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 os + +import pytest + +import export_model_sample + +PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") +MODEL_ID = ( + "3422489426196955136" # permanent_swim_run_videos_action_recognition_edge_model +) +GCS_URI = ( + "gs://ucaip-samples-test-output/tmp/export_model_sample" +) + + +@pytest.fixture(scope="function", autouse=True) +def teardown(storage_client): + yield + + bucket = storage_client.get_bucket("ucaip-samples-test-output") + blobs = bucket.list_blobs(prefix="tmp/export_model_sample") + for blob in blobs: + blob.delete() + + +def test_export_model_sample(capsys): + export_model_sample.export_model_sample( + project=PROJECT_ID, + model_id=MODEL_ID, + gcs_destination_output_uri_prefix=GCS_URI + ) + out, _ = capsys.readouterr() + assert "output_info" in out diff --git a/samples/snippets/predict_custom_trained_model_sample_test.py b/samples/snippets/predict_custom_trained_model_sample_test.py index 9b3a60df2a..b3cc1ddaf6 100644 --- a/samples/snippets/predict_custom_trained_model_sample_test.py +++ b/samples/snippets/predict_custom_trained_model_sample_test.py @@ -37,4 +37,4 @@ def test_ucaip_generated_predict_custom_trained_model_sample(capsys): ) out, _ = capsys.readouterr() - assert "number_value: 1.0" in out + assert "1.0" in out diff --git a/samples/snippets/predict_image_object_detection_sample_test.py b/samples/snippets/predict_image_object_detection_sample_test.py index c4f4893a87..8c2eb2e99f 100644 --- a/samples/snippets/predict_image_object_detection_sample_test.py +++ b/samples/snippets/predict_image_object_detection_sample_test.py @@ -31,4 +31,4 @@ def test_ucaip_generated_predict_image_object_detection_sample(capsys): ) out, _ = capsys.readouterr() - assert 'string_value: "Salad"' in out + assert 'Salad' in out diff --git a/samples/snippets/predict_tabular_classification_sample_test.py b/samples/snippets/predict_tabular_classification_sample_test.py index 51eed490bd..bc85447ddb 100644 --- a/samples/snippets/predict_tabular_classification_sample_test.py +++ b/samples/snippets/predict_tabular_classification_sample_test.py @@ -35,4 +35,4 @@ def test_ucaip_generated_predict_tabular_classification_sample(capsys): ) out, _ = capsys.readouterr() - assert 'string_value: "setosa"' in out + assert 'setosa' in out diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 18314ffe0b..7371c65396 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ pytest==6.2.2 google-cloud-storage>=1.26.0, <2.0.0dev -google-cloud-aiplatform==0.4.0 +google-cloud-aiplatform==0.5.0 diff --git a/setup.py b/setup.py index bb807572be..a290702738 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ import setuptools # type: ignore name = "google-cloud-aiplatform" -version = "0.5.0" +version = "0.5.1" description = "Cloud AI Platform API client library" package_root = os.path.abspath(os.path.dirname(__file__))