GeezerVison is showing github.com — chore: merge main into dev (#162) · googleapis/python-aiplatform@9e1087a
File treeExpand file treeCollapse file tree Open diff view settings .sample_configs/param_handlers
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/CODEOWNERS +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | # yoshi-python is the default owner | 8 | 8 | * @googleapis/yoshi-python | 9 | 9 |
| | 10 | +# The AI Platform GAPIC libraries are owned by Cloud AI DPE | | 11 | +/google/cloud/aiplatform* @googleapis/cdpe-cloudai | | 12 | + | | 13 | +# The AI Platform SDK is owned by Model Builder SDK Dev team | | 14 | +/google/cloud/aiplatform/* @googleapis/cloud-aiplatform-model-builder-sdk | | 15 | + | 10 | 16 | # The python-samples-owners team is the default owner for samples | 11 | 17 | /samples/**/*.py @dizcology @googleapis/python-samples-owners | 12 | 18 |
| 13 | 19 | # The enhanced client library tests are owned by @telpirion | 14 | | -/tests/unit/enhanced_library/*.py @telpirion | | 20 | +/tests/unit/enhanced_library/*.py @telpirion |
Collapse file Copy file name to clipboard +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +def make_parent(parent: str) -> str: | | 2 | + parent = parent | | 3 | + | | 4 | + return parent | | 5 | + | | 6 | + | | 7 | +def make_batch_prediction_job( | | 8 | + display_name: str, | | 9 | + model_name: str, | | 10 | + gcs_source_uri: str, | | 11 | + gcs_destination_output_uri_prefix: str, | | 12 | + predictions_format: str, | | 13 | +) -> google.cloud.aiplatform_v1beta1.types.batch_prediction_job.BatchPredictionJob: | | 14 | + batch_prediction_job = { | | 15 | + "display_name": display_name, | | 16 | + # Format: 'projects/{project}/locations/{location}/models/{model_id}' | | 17 | + "model": model_name, | | 18 | + "input_config": { | | 19 | + "instances_format": predictions_format, | | 20 | + "gcs_source": {"uris": [gcs_source_uri]}, | | 21 | + }, | | 22 | + "output_config": { | | 23 | + "predictions_format": predictions_format, | | 24 | + "gcs_destination": {"output_uri_prefix": gcs_destination_output_uri_prefix}, | | 25 | + }, | | 26 | + } | | 27 | + return batch_prediction_job | | 28 | + |
Collapse file Copy file name to clipboard +54Lines changed: 54 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Copyright 2020 Google LLC | | 2 | +# | | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 4 | +# you may not use this file except in compliance with the License. | | 5 | +# You may obtain a copy of the License at | | 6 | +# | | 7 | +# https://www.apache.org/licenses/LICENSE-2.0 | | 8 | +# | | 9 | +# Unless required by applicable law or agreed to in writing, software | | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 12 | +# See the License for the specific language governing permissions and | | 13 | +# limitations under the License. | | 14 | + | | 15 | +# [START aiplatform_create_batch_prediction_job_tabular_forecasting_sample] | | 16 | +from google.cloud import aiplatform | | 17 | + | | 18 | + | | 19 | +def create_batch_prediction_job_tabular_forecasting_sample( | | 20 | + project: str, | | 21 | + display_name: str, | | 22 | + model_name: str, | | 23 | + gcs_source_uri: str, | | 24 | + gcs_destination_output_uri_prefix: str, | | 25 | + predictions_format: str, | | 26 | + location: str = "us-central1", | | 27 | + api_endpoint: str = "us-central1-aiplatform.googleapis.com", | | 28 | +): | | 29 | + # The AI Platform services require regional API endpoints. | | 30 | + client_options = {"api_endpoint": api_endpoint} | | 31 | + # Initialize client that will be used to create and send requests. | | 32 | + # This client only needs to be created once, and can be reused for multiple requests. | | 33 | + client = aiplatform.gapic.JobServiceClient(client_options=client_options) | | 34 | + batch_prediction_job = { | | 35 | + "display_name": display_name, | | 36 | + # Format: 'projects/{project}/locations/{location}/models/{model_id}' | | 37 | + "model": model_name, | | 38 | + "input_config": { | | 39 | + "instances_format": predictions_format, | | 40 | + "gcs_source": {"uris": [gcs_source_uri]}, | | 41 | + }, | | 42 | + "output_config": { | | 43 | + "predictions_format": predictions_format, | | 44 | + "gcs_destination": {"output_uri_prefix": gcs_destination_output_uri_prefix}, | | 45 | + }, | | 46 | + } | | 47 | + parent = f"projects/{project}/locations/{location}" | | 48 | + response = client.create_batch_prediction_job( | | 49 | + parent=parent, batch_prediction_job=batch_prediction_job | | 50 | + ) | | 51 | + print("response:", response) | | 52 | + | | 53 | + | | 54 | +# [END aiplatform_create_batch_prediction_job_tabular_forecasting_sample] |
Collapse file Copy file name to clipboard +54Lines changed: 54 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Copyright 2020 Google LLC | | 2 | +# | | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 4 | +# you may not use this file except in compliance with the License. | | 5 | +# You may obtain a copy of the License at | | 6 | +# | | 7 | +# https://www.apache.org/licenses/LICENSE-2.0 | | 8 | +# | | 9 | +# Unless required by applicable law or agreed to in writing, software | | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 12 | +# See the License for the specific language governing permissions and | | 13 | +# limitations under the License. | | 14 | + | | 15 | +import os | | 16 | +from uuid import uuid4 | | 17 | + | | 18 | +import pytest | | 19 | + | | 20 | +import create_batch_prediction_job_tabular_forecasting_sample | | 21 | +import helpers | | 22 | + | | 23 | +PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") | | 24 | +LOCATION = "us-central1" | | 25 | +MODEL_ID = "8531330622239539200" # Permanent restaurant rating model | | 26 | +DISPLAY_NAME = f"temp_create_batch_prediction_tabular_forecasting_test_{uuid4()}" | | 27 | +GCS_SOURCE_URI = "gs://cloud-samples-data/ai-platform/covid/bigquery-public-covid-nyt-us-counties-train.csv" | | 28 | +GCS_OUTPUT_URI = "gs://ucaip-samples-test-output/" | | 29 | +PREDICTIONS_FORMAT = "csv" | | 30 | + | | 31 | + | | 32 | +@pytest.fixture(scope="function", autouse=True) | | 33 | +def teardown(teardown_batch_prediction_job): | | 34 | + yield | | 35 | + | | 36 | + | | 37 | +# Creating AutoML Tabular Forecasting Classification batch prediction job | | 38 | +def test_create_batch_prediction_job_tabular_forecasting_sample(capsys, shared_state): | | 39 | + | | 40 | + model_name = f"projects/{PROJECT_ID}/locations/{LOCATION}/models/{MODEL_ID}" | | 41 | + | | 42 | + create_batch_prediction_job_tabular_forecasting_sample.create_batch_prediction_job_tabular_forecasting_sample( | | 43 | + project=PROJECT_ID, | | 44 | + display_name=DISPLAY_NAME, | | 45 | + model_name=model_name, | | 46 | + gcs_source_uri=GCS_SOURCE_URI, | | 47 | + gcs_destination_output_uri_prefix=GCS_OUTPUT_URI, | | 48 | + predictions_format=PREDICTIONS_FORMAT, | | 49 | + ) | | 50 | + | | 51 | + out, _ = capsys.readouterr() | | 52 | + | | 53 | + # Save resource name of the newly created batch prediction job | | 54 | + shared_state["batch_prediction_job_name"] = helpers.get_name(out) |
Collapse file Copy file name to clipboardExpand all lines: testing/constraints-3.10.txt Collapse file Copy file name to clipboardExpand all lines: testing/constraints-3.11.txt Collapse file Copy file name to clipboard +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# This constraints file is used to check that lower bounds | | 2 | +# are correct in setup.py | | 3 | +# List *all* library dependencies and extras in this file. | | 4 | +# Pin the version to the lower bound. | | 5 | +# | | 6 | +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", | | 7 | +# Then this file should have foo==1.14.0 | | 8 | +google-api-core==1.22.2 | | 9 | +libcst==0.2.5 | | 10 | +proto-plus==1.10.1 | | 11 | +mock==4.0.2 | | 12 | +google-cloud-storage==1.26.0 |
Collapse file Copy file name to clipboardExpand all lines: testing/constraints-3.7.txt
|