From 578e06df481c3d60074a7b8e9365f8361b04e32b Mon Sep 17 00:00:00 2001 From: Vinny Senthil Date: Tue, 7 Dec 2021 10:34:49 -0800 Subject: [PATCH] fix: Minor docstring and snippet fixes (#873) * docs: Update batch prediction job instance, predict format docstrings * Update AutoML predict snippets to refer to correct YAML Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- .sample_configs/process_configs.yaml | 15 ++++++--------- google/cloud/aiplatform/jobs.py | 13 +++++++------ google/cloud/aiplatform/models.py | 13 +++++++------ .../predict_image_classification_sample.py | 2 +- .../predict_tabular_classification_sample.py | 2 +- .../predict_tabular_regression_sample.py | 2 +- ...ict_text_classification_single_label_sample.py | 2 +- .../predict_text_entity_extraction_sample.py | 2 +- .../predict_text_sentiment_analysis_sample.py | 2 +- 9 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.sample_configs/process_configs.yaml b/.sample_configs/process_configs.yaml index 4e6608b4fd..91c8b61c8f 100644 --- a/.sample_configs/process_configs.yaml +++ b/.sample_configs/process_configs.yaml @@ -266,7 +266,7 @@ predict_image_classification_sample: instance_dict: predict.instance.ImageClassificationPredictionInstance parameters_dict: predict.params.ImageClassificationPredictionParams comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/classification.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/image_classification_1.0.0.yaml for the format of the predictions. predict_image_file_sample: max_depth: 1 @@ -278,7 +278,7 @@ predict_image_object_detection_sample: instance_dict: predict.instance.ImageObjectDetectionPredictionInstance parameters_dict: predict.params.ImageObjectDetectionPredictionParams comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/image_object_detection.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/image_object_detection_1.0.0.yaml for the format of the predictions. predict_sample: max_depth: 1 @@ -290,30 +290,27 @@ predict_tabular_classification_sample: max_depth: 1 resource_name: endpoint comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/tables_classification.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/tabular_classification_1.0.0.yaml for the format of the predictions. predict_tabular_forecasting_sample: {} predict_tabular_regression_sample: max_depth: 1 resource_name: endpoint comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/tables_regression.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/tabular_regression_1.0.0.yaml for the format of the predictions. predict_text_classification_single_label_sample: max_depth: 1 resource_name: endpoint schema_types: instance_dict: predict.instance.TextClassificationPredictionInstance - comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/text_classification.yaml - for the format of the predictions. predict_text_entity_extraction_sample: max_depth: 1 resource_name: endpoint schema_types: instance_dict: predict.instance.TextExtractionPredictionInstance comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/text_extraction.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/text_extraction_1.0.0.yaml for the format of the predictions. predict_text_sentiment_analysis_sample: max_depth: 1 @@ -321,7 +318,7 @@ predict_text_sentiment_analysis_sample: schema_types: instance_dict: predict.instance.TextSentimentPredictionInstance comments: - predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/text_sentiment.yaml + predictions: See gs://google-cloud-aiplatform/schema/predict/prediction/text_sentiment_1.0.0.yaml for the format of the predictions. search_migratable_resources_sample: {} undeploy_model_sample: diff --git a/google/cloud/aiplatform/jobs.py b/google/cloud/aiplatform/jobs.py index 57958fc779..ae920ab2f3 100644 --- a/google/cloud/aiplatform/jobs.py +++ b/google/cloud/aiplatform/jobs.py @@ -380,13 +380,14 @@ def create( Or an instance of aiplatform.Model. instances_format (str): - Required. The format in which instances are given, must be one - of "jsonl", "csv", "bigquery", "tf-record", "tf-record-gzip", - or "file-list". Default is "jsonl" when using `gcs_source`. If a - `bigquery_source` is provided, this is overridden to "bigquery". + Required. The format in which instances are provided. Must be one + of the formats listed in `Model.supported_input_storage_formats`. + Default is "jsonl" when using `gcs_source`. If a `bigquery_source` + is provided, this is overridden to "bigquery". predictions_format (str): - Required. The format in which Vertex AI gives the - predictions, must be one of "jsonl", "csv", or "bigquery". + Required. The format in which Vertex AI outputs the + predictions, must be one of the formats specified in + `Model.supported_output_storage_formats`. Default is "jsonl" when using `gcs_destination_prefix`. If a `bigquery_destination_prefix` is provided, this is overridden to "bigquery". diff --git a/google/cloud/aiplatform/models.py b/google/cloud/aiplatform/models.py index 87af6b16bf..17ddc5c70d 100644 --- a/google/cloud/aiplatform/models.py +++ b/google/cloud/aiplatform/models.py @@ -2099,10 +2099,10 @@ def batch_predict( BigQuery URI to a table, up to 2000 characters long. For example: `bq://projectId.bqDatasetId.bqTableId` instances_format: str = "jsonl" - Required. The format in which instances are given, must be one - of "jsonl", "csv", "bigquery", "tf-record", "tf-record-gzip", - or "file-list". Default is "jsonl" when using `gcs_source`. If a - `bigquery_source` is provided, this is overridden to "bigquery". + The format in which instances are provided. Must be one + of the formats listed in `Model.supported_input_storage_formats`. + Default is "jsonl" when using `gcs_source`. If a `bigquery_source` + is provided, this is overridden to "bigquery". gcs_destination_prefix: Optional[str] = None The Google Cloud Storage location of the directory where the output is to be written to. In the given directory a new @@ -2145,8 +2145,9 @@ def batch_predict( ```google.rpc.Status`` `__ represented as a STRUCT, and containing only ``code`` and ``message``. predictions_format: str = "jsonl" - Required. The format in which Vertex AI gives the - predictions, must be one of "jsonl", "csv", or "bigquery". + Required. The format in which Vertex AI outputs the + predictions, must be one of the formats specified in + `Model.supported_output_storage_formats`. Default is "jsonl" when using `gcs_destination_prefix`. If a `bigquery_destination_prefix` is provided, this is overridden to "bigquery". diff --git a/samples/snippets/prediction_service/predict_image_classification_sample.py b/samples/snippets/prediction_service/predict_image_classification_sample.py index 0e0253d341..48a88bd256 100644 --- a/samples/snippets/prediction_service/predict_image_classification_sample.py +++ b/samples/snippets/prediction_service/predict_image_classification_sample.py @@ -52,7 +52,7 @@ def predict_image_classification_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/classification.yaml for the format of the predictions. + # See gs://google-cloud-aiplatform/schema/predict/prediction/image_classification_1.0.0.yaml for the format of the predictions. predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction)) diff --git a/samples/snippets/prediction_service/predict_tabular_classification_sample.py b/samples/snippets/prediction_service/predict_tabular_classification_sample.py index a9df7678a7..7de71ab38d 100644 --- a/samples/snippets/prediction_service/predict_tabular_classification_sample.py +++ b/samples/snippets/prediction_service/predict_tabular_classification_sample.py @@ -46,7 +46,7 @@ def predict_tabular_classification_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/tables_classification.yaml for the format of the predictions. + # See gs://google-cloud-aiplatform/schema/predict/prediction/tabular_classification_1.0.0.yaml for the format of the predictions. predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction)) diff --git a/samples/snippets/prediction_service/predict_tabular_regression_sample.py b/samples/snippets/prediction_service/predict_tabular_regression_sample.py index 7f76dc6f17..2cd970c4f7 100644 --- a/samples/snippets/prediction_service/predict_tabular_regression_sample.py +++ b/samples/snippets/prediction_service/predict_tabular_regression_sample.py @@ -46,7 +46,7 @@ def predict_tabular_regression_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/tables_regression.yaml for the format of the predictions. + # See gs://google-cloud-aiplatform/schema/predict/prediction/tabular_regression_1.0.0.yaml for the format of the predictions. predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction)) diff --git a/samples/snippets/prediction_service/predict_text_classification_single_label_sample.py b/samples/snippets/prediction_service/predict_text_classification_single_label_sample.py index c0579224ef..38e72f11e6 100644 --- a/samples/snippets/prediction_service/predict_text_classification_single_label_sample.py +++ b/samples/snippets/prediction_service/predict_text_classification_single_label_sample.py @@ -45,7 +45,7 @@ def predict_text_classification_single_label_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/text_classification.yaml for the format of the predictions. + predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction)) diff --git a/samples/snippets/prediction_service/predict_text_entity_extraction_sample.py b/samples/snippets/prediction_service/predict_text_entity_extraction_sample.py index be70a3c075..97b354b874 100644 --- a/samples/snippets/prediction_service/predict_text_entity_extraction_sample.py +++ b/samples/snippets/prediction_service/predict_text_entity_extraction_sample.py @@ -46,7 +46,7 @@ def predict_text_entity_extraction_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/text_extraction.yaml for the format of the predictions. + # See gs://google-cloud-aiplatform/schema/predict/prediction/text_extraction_1.0.0.yaml for the format of the predictions. predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction)) diff --git a/samples/snippets/prediction_service/predict_text_sentiment_analysis_sample.py b/samples/snippets/prediction_service/predict_text_sentiment_analysis_sample.py index 934bc5da9e..f8e66afaa2 100644 --- a/samples/snippets/prediction_service/predict_text_sentiment_analysis_sample.py +++ b/samples/snippets/prediction_service/predict_text_sentiment_analysis_sample.py @@ -45,7 +45,7 @@ def predict_text_sentiment_analysis_sample( ) print("response") print(" deployed_model_id:", response.deployed_model_id) - # See gs://google-cloud-aiplatform/schema/predict/prediction/text_sentiment.yaml for the format of the predictions. + # See gs://google-cloud-aiplatform/schema/predict/prediction/text_sentiment_1.0.0.yaml for the format of the predictions. predictions = response.predictions for prediction in predictions: print(" prediction:", dict(prediction))