diff --git a/samples/snippets/cancel_training_pipeline_sample_test.py b/samples/snippets/cancel_training_pipeline_sample_test.py index 9ffb601e42..e16b384c22 100644 --- a/samples/snippets/cancel_training_pipeline_sample_test.py +++ b/samples/snippets/cancel_training_pipeline_sample_test.py @@ -12,18 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_sample import cancel_training_pipeline_sample +import create_training_pipeline_sample import delete_training_pipeline_sample -import get_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_text_classification_sample_test.py b/samples/snippets/create_batch_prediction_job_text_classification_sample_test.py index 86d73b5ac2..003b858416 100644 --- a/samples/snippets/create_batch_prediction_job_text_classification_sample_test.py +++ b/samples/snippets/create_batch_prediction_job_text_classification_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_batch_prediction_job_text_classification_sample import cancel_batch_prediction_job_sample +import create_batch_prediction_job_text_classification_sample import delete_batch_prediction_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_text_entity_extraction_sample_test.py b/samples/snippets/create_batch_prediction_job_text_entity_extraction_sample_test.py index c86395d623..069730a9b5 100644 --- a/samples/snippets/create_batch_prediction_job_text_entity_extraction_sample_test.py +++ b/samples/snippets/create_batch_prediction_job_text_entity_extraction_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_batch_prediction_job_text_entity_extraction_sample import cancel_batch_prediction_job_sample +import create_batch_prediction_job_text_entity_extraction_sample import delete_batch_prediction_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_text_sentiment_analysis_sample_test.py b/samples/snippets/create_batch_prediction_job_text_sentiment_analysis_sample_test.py index d3fc196707..192312086f 100644 --- a/samples/snippets/create_batch_prediction_job_text_sentiment_analysis_sample_test.py +++ b/samples/snippets/create_batch_prediction_job_text_sentiment_analysis_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_batch_prediction_job_text_sentiment_analysis_sample import cancel_batch_prediction_job_sample +import create_batch_prediction_job_text_sentiment_analysis_sample import delete_batch_prediction_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_video_action_recognition_test.py b/samples/snippets/create_batch_prediction_job_video_action_recognition_test.py index d489cb421d..269410ac17 100644 --- a/samples/snippets/create_batch_prediction_job_video_action_recognition_test.py +++ b/samples/snippets/create_batch_prediction_job_video_action_recognition_test.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import pytest import os +import uuid -import helpers +from google.cloud import aiplatform +import pytest import create_batch_prediction_job_video_action_recognition_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_video_classification_sample_test.py b/samples/snippets/create_batch_prediction_job_video_classification_sample_test.py index 41752dc12b..f9344ab6ec 100644 --- a/samples/snippets/create_batch_prediction_job_video_classification_sample_test.py +++ b/samples/snippets/create_batch_prediction_job_video_classification_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_batch_prediction_job_video_classification_sample import cancel_batch_prediction_job_sample +import create_batch_prediction_job_video_classification_sample import delete_batch_prediction_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_batch_prediction_job_video_object_tracking_sample_test.py b/samples/snippets/create_batch_prediction_job_video_object_tracking_sample_test.py index 6ac8660193..46ace425d6 100644 --- a/samples/snippets/create_batch_prediction_job_video_object_tracking_sample_test.py +++ b/samples/snippets/create_batch_prediction_job_video_object_tracking_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_batch_prediction_job_video_object_tracking_sample import cancel_batch_prediction_job_sample +import create_batch_prediction_job_video_object_tracking_sample import delete_batch_prediction_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/create_custom_job_sample_test.py b/samples/snippets/create_custom_job_sample_test.py index affc2895f0..2b699b2061 100644 --- a/samples/snippets/create_custom_job_sample_test.py +++ b/samples/snippets/create_custom_job_sample_test.py @@ -13,17 +13,16 @@ # limitations under the License. -import pytest -import uuid import os +import uuid -import helpers +from google.cloud import aiplatform +import pytest import cancel_custom_job_sample import create_custom_job_sample import delete_custom_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") CONTAINER_IMAGE_URI = "gcr.io/ucaip-test/ucaip-training-test:latest" diff --git a/samples/snippets/create_data_labeling_job_active_learning_test.py b/samples/snippets/create_data_labeling_job_active_learning_test.py index 38a7c0c1c0..fff2eff6f4 100644 --- a/samples/snippets/create_data_labeling_job_active_learning_test.py +++ b/samples/snippets/create_data_labeling_job_active_learning_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os import uuid -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_active_learning_sample +import helpers API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_data_labeling_job_image_segmentation_test.py b/samples/snippets/create_data_labeling_job_image_segmentation_test.py index 3e78657484..5ed031e11b 100644 --- a/samples/snippets/create_data_labeling_job_image_segmentation_test.py +++ b/samples/snippets/create_data_labeling_job_image_segmentation_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os import uuid -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_image_segmentation_sample +import helpers API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_data_labeling_job_images_sample_test.py b/samples/snippets/create_data_labeling_job_images_sample_test.py index 8d99132f18..ae5bdce280 100644 --- a/samples/snippets/create_data_labeling_job_images_sample_test.py +++ b/samples/snippets/create_data_labeling_job_images_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os from uuid import uuid4 -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_images_sample -import cancel_data_labeling_job_sample -import delete_data_labeling_job_sample +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") diff --git a/samples/snippets/create_data_labeling_job_sample_test.py b/samples/snippets/create_data_labeling_job_sample_test.py index dc9a0baacb..220628d8ba 100644 --- a/samples/snippets/create_data_labeling_job_sample_test.py +++ b/samples/snippets/create_data_labeling_job_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os from uuid import uuid4 -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_sample -import cancel_data_labeling_job_sample -import delete_data_labeling_job_sample +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") diff --git a/samples/snippets/create_data_labeling_job_specialist_pool_test.py b/samples/snippets/create_data_labeling_job_specialist_pool_test.py index 8936fa6776..afb49613fb 100644 --- a/samples/snippets/create_data_labeling_job_specialist_pool_test.py +++ b/samples/snippets/create_data_labeling_job_specialist_pool_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os import uuid -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_specialist_pool_sample +import helpers API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_data_labeling_job_video_sample_test.py b/samples/snippets/create_data_labeling_job_video_sample_test.py index 74b20147f9..6d782e4887 100644 --- a/samples/snippets/create_data_labeling_job_video_sample_test.py +++ b/samples/snippets/create_data_labeling_job_video_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os from uuid import uuid4 -from google.cloud import aiplatform -import helpers +from google.cloud import aiplatform +import pytest import create_data_labeling_job_video_sample -import cancel_data_labeling_job_sample -import delete_data_labeling_job_sample +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") API_ENDPOINT = os.getenv("DATA_LABELING_API_ENDPOINT") diff --git a/samples/snippets/create_dataset_image_sample_test.py b/samples/snippets/create_dataset_image_sample_test.py index ea2f2607ca..3d7664a14a 100644 --- a/samples/snippets/create_dataset_image_sample_test.py +++ b/samples/snippets/create_dataset_image_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 import pytest -import os - -import helpers import create_dataset_image_sample import delete_dataset_sample - +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_dataset_sample_test.py b/samples/snippets/create_dataset_sample_test.py index 3508092e8c..d0a674f101 100644 --- a/samples/snippets/create_dataset_sample_test.py +++ b/samples/snippets/create_dataset_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 import pytest -import os - -import helpers import create_dataset_sample import delete_dataset_sample - +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") IMAGE_METADATA_SCHEMA_URI = ( diff --git a/samples/snippets/create_dataset_tabular_bigquery_sample_test.py b/samples/snippets/create_dataset_tabular_bigquery_sample_test.py index a582760cfe..53f03de97f 100644 --- a/samples/snippets/create_dataset_tabular_bigquery_sample_test.py +++ b/samples/snippets/create_dataset_tabular_bigquery_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 import pytest -import os - -import helpers import create_dataset_tabular_bigquery_sample import delete_dataset_sample - +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") BIGQUERY_URI = "bq://ucaip-sample-tests.table_test.all_bq_types" diff --git a/samples/snippets/create_dataset_tabular_gcs_sample_test.py b/samples/snippets/create_dataset_tabular_gcs_sample_test.py index 3206a56e97..98e21c881e 100644 --- a/samples/snippets/create_dataset_tabular_gcs_sample_test.py +++ b/samples/snippets/create_dataset_tabular_gcs_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 import pytest -import os - -import helpers import create_dataset_tabular_gcs_sample import delete_dataset_sample - +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") GCS_URI = "gs://ucaip-sample-resources/iris_1000.csv" diff --git a/samples/snippets/create_dataset_video_sample_test.py b/samples/snippets/create_dataset_video_sample_test.py index 844a25c204..1e6f85b6bd 100644 --- a/samples/snippets/create_dataset_video_sample_test.py +++ b/samples/snippets/create_dataset_video_sample_test.py @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 import pytest -import os - -import helpers import create_dataset_video_sample import delete_dataset_sample - +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") VIDEO_METADATA_SCHEMA_URI = ( diff --git a/samples/snippets/create_endpoint_sample_test.py b/samples/snippets/create_endpoint_sample_test.py index cca027cdfc..2613a4afd0 100644 --- a/samples/snippets/create_endpoint_sample_test.py +++ b/samples/snippets/create_endpoint_sample_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os from uuid import uuid4 -import helpers +import pytest import create_endpoint_sample import delete_endpoint_sample +import helpers DISPLAY_NAME = f"temp_create_endpoint_test_{uuid4()}" PROJECT = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_hyperparameter_tuning_job_python_package_sample_test.py b/samples/snippets/create_hyperparameter_tuning_job_python_package_sample_test.py index 6ec111bcac..ab8e975fcd 100644 --- a/samples/snippets/create_hyperparameter_tuning_job_python_package_sample_test.py +++ b/samples/snippets/create_hyperparameter_tuning_job_python_package_sample_test.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import pytest import os +import uuid -import helpers +from google.cloud import aiplatform +import pytest import create_hyperparameter_tuning_job_python_package_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/create_hyperparameter_tuning_job_sample_test.py b/samples/snippets/create_hyperparameter_tuning_job_sample_test.py index 21b16121fb..78799d7554 100644 --- a/samples/snippets/create_hyperparameter_tuning_job_sample_test.py +++ b/samples/snippets/create_hyperparameter_tuning_job_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import pytest import os +import uuid -import helpers +from google.cloud import aiplatform +import pytest import cancel_hyperparameter_tuning_job_sample import create_hyperparameter_tuning_job_sample import delete_hyperparameter_tuning_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") CONTAINER_IMAGE_URI = "gcr.io/ucaip-test/ucaip-training-test:latest" diff --git a/samples/snippets/create_training_pipeline_custom_job_sample.py b/samples/snippets/create_training_pipeline_custom_job_sample.py index f9e22bc867..e12a98b9ea 100644 --- a/samples/snippets/create_training_pipeline_custom_job_sample.py +++ b/samples/snippets/create_training_pipeline_custom_job_sample.py @@ -63,7 +63,7 @@ def create_training_pipeline_custom_job_sample( "training_task_inputs": training_task_inputs, "model_to_upload": { "display_name": model_display_name, - "container_spec": {"image_uri": image_uri, }, + "container_spec": {"image_uri": image_uri}, }, } parent = f"projects/{project}/locations/{location}" diff --git a/samples/snippets/create_training_pipeline_custom_job_sample_test.py b/samples/snippets/create_training_pipeline_custom_job_sample_test.py index fc593a5d44..1d3655c6f3 100644 --- a/samples/snippets/create_training_pipeline_custom_job_sample_test.py +++ b/samples/snippets/create_training_pipeline_custom_job_sample_test.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest import create_training_pipeline_custom_job_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DISPLAY_NAME = f"temp_create_training_pipeline_custom_job_test_{uuid4()}" @@ -44,7 +43,7 @@ def pipeline_client(): def teardown(shared_state, pipeline_client): yield - training_pipeline_id = shared_state["training_pipeline_name"].split("/")[-1] + shared_state["training_pipeline_name"].split("/")[-1] pipeline_client.cancel_training_pipeline( name=shared_state["training_pipeline_name"] diff --git a/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample.py b/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample.py index 3638b53abc..b8966697a1 100644 --- a/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample.py +++ b/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample.py @@ -32,10 +32,8 @@ def create_training_pipeline_custom_training_managed_dataset_sample( ): client_options = {"api_endpoint": api_endpoint} # Initialize client that will be used to create and send requests. - # This client only needs to be created once, and can be reused for - # multiple requests. - client = aiplatform.gapic.PipelineServiceClient( - client_options=client_options) + # This client only needs to be created once, and can be reused for multiple requests. + client = aiplatform.gapic.PipelineServiceClient(client_options=client_options) # input_data_config input_data_config = { @@ -45,14 +43,13 @@ def create_training_pipeline_custom_training_managed_dataset_sample( } # training_task_definition - custom_task_definition = "gs://google-cloud-aiplatform/schema/" \ - "trainingjob/definition/custom_task_1.0.0.yaml" + custom_task_definition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/custom_task_1.0.0.yaml" # training_task_inputs training_container_spec = { "imageUri": training_container_spec_image_uri, # AIP_MODEL_DIR is set by the service according to baseOutputDirectory. - "args": ["--model-dir=$(AIP_MODEL_DIR)",], + "args": ["--model-dir=$(AIP_MODEL_DIR)"], } training_worker_pool_spec = { @@ -66,25 +63,16 @@ def create_training_pipeline_custom_training_managed_dataset_sample( "baseOutputDirectory": {"outputUriPrefix": base_output_uri_prefix}, } - training_task_inputs = json_format.ParseDict( - training_task_inputs_dict, Value()) + training_task_inputs = json_format.ParseDict(training_task_inputs_dict, Value()) # model_to_upload model_container_spec = { "image_uri": model_container_spec_image_uri, - "command": ["/bin/tensorflow_model_server"], - "args": [ - "--model_name=$(AIP_MODEL)", - "--model_base_path=$(AIP_STORAGE_URI)", - "--rest_api_port=8080", - "--port=8500", - "--file_system_poll_wait_seconds=31540000" - ], + "command": [], + "args": [], } - model = { - "display_name": model_display_name, - "container_spec": model_container_spec} + model = {"display_name": model_display_name, "container_spec": model_container_spec} training_pipeline = { "display_name": display_name, diff --git a/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample_test.py b/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample_test.py index 85c6f22734..6d75cf249c 100644 --- a/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample_test.py +++ b/samples/snippets/create_training_pipeline_custom_training_managed_dataset_sample_test.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import pytest import os +import uuid from google.cloud import aiplatform - -import helpers +import pytest import create_training_pipeline_custom_training_managed_dataset_sample +import helpers API_ENDPOINT = "us-central1-aiplatform.googleapis.com" diff --git a/samples/snippets/create_training_pipeline_image_classification_sample_test.py b/samples/snippets/create_training_pipeline_image_classification_sample_test.py index 2c4ecab9b1..89e8804a92 100644 --- a/samples/snippets/create_training_pipeline_image_classification_sample_test.py +++ b/samples/snippets/create_training_pipeline_image_classification_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_image_classification_sample import cancel_training_pipeline_sample +import create_training_pipeline_image_classification_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "1084241610289446912" # Permanent 50 Flowers Dataset diff --git a/samples/snippets/create_training_pipeline_image_object_detection_sample_test.py b/samples/snippets/create_training_pipeline_image_object_detection_sample_test.py index 0e76ae02f1..24f26f33e3 100644 --- a/samples/snippets/create_training_pipeline_image_object_detection_sample_test.py +++ b/samples/snippets/create_training_pipeline_image_object_detection_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_image_object_detection_sample import cancel_training_pipeline_sample +import create_training_pipeline_image_object_detection_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "3555732643297361920" # permanent_salad_object_detection_dataset diff --git a/samples/snippets/create_training_pipeline_sample_test.py b/samples/snippets/create_training_pipeline_sample_test.py index 1903ff4ce3..4677004e4e 100644 --- a/samples/snippets/create_training_pipeline_sample_test.py +++ b/samples/snippets/create_training_pipeline_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_sample import cancel_training_pipeline_sample +import create_training_pipeline_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "1084241610289446912" # Permanent 50 Flowers Dataset diff --git a/samples/snippets/create_training_pipeline_tabular_classification_sample_test.py b/samples/snippets/create_training_pipeline_tabular_classification_sample_test.py index 66cedbbd09..fe61a82188 100644 --- a/samples/snippets/create_training_pipeline_tabular_classification_sample_test.py +++ b/samples/snippets/create_training_pipeline_tabular_classification_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_tabular_classification_sample import cancel_training_pipeline_sample +import create_training_pipeline_tabular_classification_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "2438839935709478912" # iris 1000 diff --git a/samples/snippets/create_training_pipeline_tabular_regression_sample_test.py b/samples/snippets/create_training_pipeline_tabular_regression_sample_test.py index 1b43876902..ab126f8df9 100644 --- a/samples/snippets/create_training_pipeline_tabular_regression_sample_test.py +++ b/samples/snippets/create_training_pipeline_tabular_regression_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_tabular_regression_sample import cancel_training_pipeline_sample +import create_training_pipeline_tabular_regression_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "3019804287640272896" # bq all diff --git a/samples/snippets/create_training_pipeline_text_entity_extraction_sample_test.py b/samples/snippets/create_training_pipeline_text_entity_extraction_sample_test.py index a904d3d114..4f54c0fc51 100644 --- a/samples/snippets/create_training_pipeline_text_entity_extraction_sample_test.py +++ b/samples/snippets/create_training_pipeline_text_entity_extraction_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_text_entity_extraction_sample import cancel_training_pipeline_sample +import create_training_pipeline_text_entity_extraction_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "6203215905493614592" # Permanent text entity extraction dataset diff --git a/samples/snippets/create_training_pipeline_text_sentiment_analysis_sample_test.py b/samples/snippets/create_training_pipeline_text_sentiment_analysis_sample_test.py index cb86ce3c24..ecaa041cc6 100644 --- a/samples/snippets/create_training_pipeline_text_sentiment_analysis_sample_test.py +++ b/samples/snippets/create_training_pipeline_text_sentiment_analysis_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_text_sentiment_analysis_sample import cancel_training_pipeline_sample +import create_training_pipeline_text_sentiment_analysis_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "5148529167758786560" # Permanent text sentiment analysis dataset diff --git a/samples/snippets/create_training_pipeline_video_action_recognition_test.py b/samples/snippets/create_training_pipeline_video_action_recognition_test.py index ab653a49e1..cd73df7286 100644 --- a/samples/snippets/create_training_pipeline_video_action_recognition_test.py +++ b/samples/snippets/create_training_pipeline_video_action_recognition_test.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import pytest import os +import uuid -import helpers +from google.cloud import aiplatform +import pytest import create_training_pipeline_video_action_recognition_sample - -from google.cloud import aiplatform +import helpers LOCATION = "us-central1" PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") @@ -49,6 +48,7 @@ def pipeline_client(): ) yield pipeline_client + @pytest.fixture(scope="function", autouse=True) def teardown(shared_state, pipeline_client): yield @@ -70,8 +70,6 @@ def teardown(shared_state, pipeline_client): ) - - # Training AutoML Vision Model def test_create_training_pipeline_video_action_recognition_sample( capsys, shared_state diff --git a/samples/snippets/create_training_pipeline_video_classification_sample_test.py b/samples/snippets/create_training_pipeline_video_classification_sample_test.py index 630a3830b6..cc0a826967 100644 --- a/samples/snippets/create_training_pipeline_video_classification_sample_test.py +++ b/samples/snippets/create_training_pipeline_video_classification_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_video_classification_sample import cancel_training_pipeline_sample +import create_training_pipeline_video_classification_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "3757409464110546944" # Permanent 5 class sports dataset diff --git a/samples/snippets/create_training_pipeline_video_object_tracking_sample_test.py b/samples/snippets/create_training_pipeline_video_object_tracking_sample_test.py index 1c1eacb4ef..fd1788ae7b 100644 --- a/samples/snippets/create_training_pipeline_video_object_tracking_sample_test.py +++ b/samples/snippets/create_training_pipeline_video_object_tracking_sample_test.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 -import pytest import os +from uuid import uuid4 -import helpers +from google.cloud import aiplatform +import pytest -import create_training_pipeline_video_object_tracking_sample import cancel_training_pipeline_sample +import create_training_pipeline_video_object_tracking_sample import delete_training_pipeline_sample - -from google.cloud import aiplatform +import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") DATASET_ID = "1138566280794603520" # Permanent 40 horses dataset diff --git a/samples/snippets/deploy_model_custom_trained_model_sample_test.py b/samples/snippets/deploy_model_custom_trained_model_sample_test.py index 49f096fdb6..43cf53cdf7 100644 --- a/samples/snippets/deploy_model_custom_trained_model_sample_test.py +++ b/samples/snippets/deploy_model_custom_trained_model_sample_test.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.cloud import aiplatform -import deploy_model_custom_trained_model_sample - +import os from uuid import uuid4 + +from google.cloud import aiplatform import pytest -import os +import deploy_model_custom_trained_model_sample import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/deploy_model_sample_test.py b/samples/snippets/deploy_model_sample_test.py index 46f8c03f2e..a3cc96b879 100644 --- a/samples/snippets/deploy_model_sample_test.py +++ b/samples/snippets/deploy_model_sample_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.cloud import aiplatform -import deploy_model_sample -import delete_endpoint_sample - +import os from uuid import uuid4 + +from google.cloud import aiplatform import pytest -import os +import delete_endpoint_sample +import deploy_model_sample import helpers PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/export_model_tabular_classification_sample_test.py b/samples/snippets/export_model_tabular_classification_sample_test.py index b0b0c7e011..90b885ba2d 100644 --- a/samples/snippets/export_model_tabular_classification_sample_test.py +++ b/samples/snippets/export_model_tabular_classification_sample_test.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os - from uuid import uuid4 -import export_model_tabular_classification_sample from google.cloud import storage +import pytest + +import export_model_tabular_classification_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") MODEL_ID = "5359002081594179584" # iris 1000 diff --git a/samples/snippets/export_model_video_action_recognition_test.py b/samples/snippets/export_model_video_action_recognition_test.py index fabb228147..ff7341114d 100644 --- a/samples/snippets/export_model_video_action_recognition_test.py +++ b/samples/snippets/export_model_video_action_recognition_test.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os -import export_model_video_action_recognition_sample from google.cloud import storage +import pytest + +import export_model_video_action_recognition_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") MODEL_ID = ( diff --git a/samples/snippets/get_custom_job_sample_test.py b/samples/snippets/get_custom_job_sample_test.py index 5e11f2d8da..f66aeb9020 100644 --- a/samples/snippets/get_custom_job_sample_test.py +++ b/samples/snippets/get_custom_job_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_custom_job_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_hyperparameter_tuning_job_sample_test.py b/samples/snippets/get_hyperparameter_tuning_job_sample_test.py index 839d056b43..06ac1627e7 100644 --- a/samples/snippets/get_hyperparameter_tuning_job_sample_test.py +++ b/samples/snippets/get_hyperparameter_tuning_job_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_hyperparameter_tuning_job_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_sample_test.py b/samples/snippets/get_model_evaluation_sample_test.py index bba69215ec..26490f4b07 100644 --- a/samples/snippets/get_model_evaluation_sample_test.py +++ b/samples/snippets/get_model_evaluation_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_slice_sample_test.py b/samples/snippets/get_model_evaluation_slice_sample_test.py index f8ed759f6d..9ce73344e8 100644 --- a/samples/snippets/get_model_evaluation_slice_sample_test.py +++ b/samples/snippets/get_model_evaluation_slice_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_slice_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_tabular_classification_sample_test.py b/samples/snippets/get_model_evaluation_tabular_classification_sample_test.py index dcfe5da069..e5e8cbc27a 100644 --- a/samples/snippets/get_model_evaluation_tabular_classification_sample_test.py +++ b/samples/snippets/get_model_evaluation_tabular_classification_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_tabular_classification_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_tabular_regression_sample_test.py b/samples/snippets/get_model_evaluation_tabular_regression_sample_test.py index a0d97b0a77..97f539d3f8 100644 --- a/samples/snippets/get_model_evaluation_tabular_regression_sample_test.py +++ b/samples/snippets/get_model_evaluation_tabular_regression_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_video_action_recognition_test.py b/samples/snippets/get_model_evaluation_video_action_recognition_test.py index 973987e086..c7218141a6 100644 --- a/samples/snippets/get_model_evaluation_video_action_recognition_test.py +++ b/samples/snippets/get_model_evaluation_video_action_recognition_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_video_object_tracking_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_video_classification_sample_test.py b/samples/snippets/get_model_evaluation_video_classification_sample_test.py index cfb8a84f29..f1de95418c 100644 --- a/samples/snippets/get_model_evaluation_video_classification_sample_test.py +++ b/samples/snippets/get_model_evaluation_video_classification_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_video_classification_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_evaluation_video_object_tracking_sample_test.py b/samples/snippets/get_model_evaluation_video_object_tracking_sample_test.py index 4777889ed7..b9d972029f 100644 --- a/samples/snippets/get_model_evaluation_video_object_tracking_sample_test.py +++ b/samples/snippets/get_model_evaluation_video_object_tracking_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_evaluation_video_object_tracking_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_model_sample_test.py b/samples/snippets/get_model_sample_test.py index baf045205e..a6990d38b5 100644 --- a/samples/snippets/get_model_sample_test.py +++ b/samples/snippets/get_model_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_model_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/get_training_pipeline_sample_test.py b/samples/snippets/get_training_pipeline_sample_test.py index 2d3a29f481..4c3726431c 100644 --- a/samples/snippets/get_training_pipeline_sample_test.py +++ b/samples/snippets/get_training_pipeline_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import get_training_pipeline_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/helpers.py b/samples/snippets/helpers.py index 15a9f31e5c..d86da0238c 100644 --- a/samples/snippets/helpers.py +++ b/samples/snippets/helpers.py @@ -19,7 +19,7 @@ def get_state(out): def wait_for_job_state( - get_job_method: Callable[[str], "proto.Message"], + get_job_method: Callable[[str], "proto.Message"], # noqa: F821 name: str, expected_state: str = "CANCELLED", timeout: int = 90, diff --git a/samples/snippets/import_data_text_classification_single_label_sample_test.py b/samples/snippets/import_data_text_classification_single_label_sample_test.py index 1ea0afaab2..afcc0786cf 100644 --- a/samples/snippets/import_data_text_classification_single_label_sample_test.py +++ b/samples/snippets/import_data_text_classification_single_label_sample_test.py @@ -13,9 +13,8 @@ # limitations under the License. -import pytest -import os -from unittest.mock import patch, mock_open, MagicMock +from unittest.mock import MagicMock, mock_open, patch + import import_data_text_classification_single_label_sample diff --git a/samples/snippets/import_data_text_entity_extraction_sample_test.py b/samples/snippets/import_data_text_entity_extraction_sample_test.py index d74c6a322c..98c5df48f9 100644 --- a/samples/snippets/import_data_text_entity_extraction_sample_test.py +++ b/samples/snippets/import_data_text_entity_extraction_sample_test.py @@ -1,11 +1,11 @@ -import pytest import os - from uuid import uuid4 + from google.cloud import aiplatform +import pytest -import import_data_text_entity_extraction_sample import delete_dataset_sample +import import_data_text_entity_extraction_sample print( f"uCAIP Library Source:\t{aiplatform.__file__}" diff --git a/samples/snippets/import_data_text_sentiment_analysis_sample_test.py b/samples/snippets/import_data_text_sentiment_analysis_sample_test.py index 3fd9b20538..b0252356f2 100644 --- a/samples/snippets/import_data_text_sentiment_analysis_sample_test.py +++ b/samples/snippets/import_data_text_sentiment_analysis_sample_test.py @@ -1,11 +1,11 @@ -import pytest import os - from uuid import uuid4 + from google.cloud import aiplatform +import pytest -import import_data_text_sentiment_analysis_sample import delete_dataset_sample +import import_data_text_sentiment_analysis_sample print( f"uCAIP Library Source:\t{aiplatform.__file__}" diff --git a/samples/snippets/import_data_video_action_recognition_test.py b/samples/snippets/import_data_video_action_recognition_test.py index cacb56de70..7a2a58b752 100644 --- a/samples/snippets/import_data_video_action_recognition_test.py +++ b/samples/snippets/import_data_video_action_recognition_test.py @@ -13,15 +13,14 @@ # limitations under the License. -import pytest import os - import uuid + from google.cloud import aiplatform +import pytest import import_data_video_action_recognition_sample - PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" GCS_SOURCE = "gs://automl-video-demo-data/ucaip-var/swimrun.jsonl" @@ -56,7 +55,7 @@ def teardown(shared_state, dataset_client): project=PROJECT_ID, location=LOCATION, dataset=shared_state["dataset_id"] ) response = dataset_client.delete_dataset(name=dataset_name) - delete_dataset_response = response.result(timeout=120) + response.result(timeout=120) def test_import_data_video_action_recognition_sample( diff --git a/samples/snippets/import_data_video_classification_sample_test.py b/samples/snippets/import_data_video_classification_sample_test.py index 0a9a1b08c9..b9d0cea46d 100644 --- a/samples/snippets/import_data_video_classification_sample_test.py +++ b/samples/snippets/import_data_video_classification_sample_test.py @@ -13,15 +13,14 @@ # limitations under the License. -import pytest import os - from uuid import uuid4 + from google.cloud import aiplatform +import pytest -import import_data_video_classification_sample import delete_dataset_sample - +import import_data_video_classification_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/import_data_video_object_tracking_sample_test.py b/samples/snippets/import_data_video_object_tracking_sample_test.py index 457bf869b5..22b2e61710 100644 --- a/samples/snippets/import_data_video_object_tracking_sample_test.py +++ b/samples/snippets/import_data_video_object_tracking_sample_test.py @@ -13,15 +13,14 @@ # limitations under the License. -import pytest import os - from uuid import uuid4 + from google.cloud import aiplatform +import pytest -import import_data_video_object_tracking_sample import delete_dataset_sample - +import import_data_video_object_tracking_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") LOCATION = "us-central1" diff --git a/samples/snippets/list_model_evaluation_slices_sample_test.py b/samples/snippets/list_model_evaluation_slices_sample_test.py index 9e7e3823c0..b5833ba90d 100644 --- a/samples/snippets/list_model_evaluation_slices_sample_test.py +++ b/samples/snippets/list_model_evaluation_slices_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import list_model_evaluation_slices_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/predict_custom_trained_model_sample.py b/samples/snippets/predict_custom_trained_model_sample.py index 308b0956fd..46fd81f03b 100644 --- a/samples/snippets/predict_custom_trained_model_sample.py +++ b/samples/snippets/predict_custom_trained_model_sample.py @@ -13,10 +13,11 @@ # limitations under the License. # [START aiplatform_predict_custom_trained_model_sample] +from typing import Dict + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -from typing import Dict def predict_custom_trained_model_sample( diff --git a/samples/snippets/predict_custom_trained_model_sample_test.py b/samples/snippets/predict_custom_trained_model_sample_test.py index 2bb19c4c95..9b3a60df2a 100644 --- a/samples/snippets/predict_custom_trained_model_sample_test.py +++ b/samples/snippets/predict_custom_trained_model_sample_test.py @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest -import os import base64 +import os import pathlib -import predict_custom_trained_model_sample +import predict_custom_trained_model_sample ENDPOINT_ID = "6119547468666372096" # permanent_custom_flowers_model PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/predict_image_classification_sample.py b/samples/snippets/predict_image_classification_sample.py index d90dd3732b..cee06ac5c3 100644 --- a/samples/snippets/predict_image_classification_sample.py +++ b/samples/snippets/predict_image_classification_sample.py @@ -13,10 +13,11 @@ # limitations under the License. # [START aiplatform_predict_image_classification_sample] +import base64 + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -import base64 def predict_image_classification_sample( diff --git a/samples/snippets/predict_image_classification_sample_test.py b/samples/snippets/predict_image_classification_sample_test.py index 828700c318..10e72bb386 100644 --- a/samples/snippets/predict_image_classification_sample_test.py +++ b/samples/snippets/predict_image_classification_sample_test.py @@ -12,13 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os -import base64 import pathlib -import predict_image_classification_sample +import predict_image_classification_sample ENDPOINT_ID = "71213169107795968" # permanent_50_flowers_endpoint PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") diff --git a/samples/snippets/predict_image_object_detection_sample.py b/samples/snippets/predict_image_object_detection_sample.py index 4d3137830f..6fb7e065f8 100644 --- a/samples/snippets/predict_image_object_detection_sample.py +++ b/samples/snippets/predict_image_object_detection_sample.py @@ -13,10 +13,11 @@ # limitations under the License. # [START aiplatform_predict_image_object_detection_sample] +import base64 + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -import base64 def predict_image_object_detection_sample( diff --git a/samples/snippets/predict_image_object_detection_sample_test.py b/samples/snippets/predict_image_object_detection_sample_test.py index 4cb4c5bdc2..c4f4893a87 100644 --- a/samples/snippets/predict_image_object_detection_sample_test.py +++ b/samples/snippets/predict_image_object_detection_sample_test.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os -import base64 import pathlib + import predict_image_object_detection_sample ENDPOINT_ID = "2791387344039575552" # permanent_salad_img_obj_detection_endpoint diff --git a/samples/snippets/predict_sample.py b/samples/snippets/predict_sample.py index d3a4a21f51..756077e25e 100644 --- a/samples/snippets/predict_sample.py +++ b/samples/snippets/predict_sample.py @@ -14,10 +14,11 @@ # [START aiplatform_predict_tutorial] # [START aiplatform_predict_sample] +from typing import Dict + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -from typing import Dict def predict_sample( diff --git a/samples/snippets/predict_tabular_classification_sample.py b/samples/snippets/predict_tabular_classification_sample.py index fb09770789..31533a0b79 100644 --- a/samples/snippets/predict_tabular_classification_sample.py +++ b/samples/snippets/predict_tabular_classification_sample.py @@ -13,10 +13,11 @@ # limitations under the License. # [START aiplatform_predict_tabular_classification_sample] +from typing import Dict + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -from typing import Dict def predict_tabular_classification_sample( diff --git a/samples/snippets/predict_tabular_classification_sample_test.py b/samples/snippets/predict_tabular_classification_sample_test.py index db3410a315..51eed490bd 100644 --- a/samples/snippets/predict_tabular_classification_sample_test.py +++ b/samples/snippets/predict_tabular_classification_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import predict_tabular_classification_sample ENDPOINT_ID = "4966625964059525120" # iris 1000 diff --git a/samples/snippets/predict_tabular_regression_sample.py b/samples/snippets/predict_tabular_regression_sample.py index 667a10ecd4..475b02432b 100644 --- a/samples/snippets/predict_tabular_regression_sample.py +++ b/samples/snippets/predict_tabular_regression_sample.py @@ -13,10 +13,11 @@ # limitations under the License. # [START aiplatform_predict_tabular_regression_sample] +from typing import Dict + from google.cloud import aiplatform from google.protobuf import json_format from google.protobuf.struct_pb2 import Value -from typing import Dict def predict_tabular_regression_sample( diff --git a/samples/snippets/predict_tabular_regression_sample_test.py b/samples/snippets/predict_tabular_regression_sample_test.py index 12af6022fc..0d98347f35 100644 --- a/samples/snippets/predict_tabular_regression_sample_test.py +++ b/samples/snippets/predict_tabular_regression_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import predict_tabular_regression_sample ENDPOINT_ID = "1014154341088493568" # bq all diff --git a/samples/snippets/predict_text_classification_single_label_sample_test.py b/samples/snippets/predict_text_classification_single_label_sample_test.py index d4c6d88a9d..be502d525d 100644 --- a/samples/snippets/predict_text_classification_single_label_sample_test.py +++ b/samples/snippets/predict_text_classification_single_label_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import predict_text_classification_single_label_sample ENDPOINT_ID = "65372563341049856" # text_classification_single_label diff --git a/samples/snippets/predict_text_entity_extraction_sample_test.py b/samples/snippets/predict_text_entity_extraction_sample_test.py index 4207b42396..cc9236afd9 100644 --- a/samples/snippets/predict_text_entity_extraction_sample_test.py +++ b/samples/snippets/predict_text_entity_extraction_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import predict_text_entity_extraction_sample ENDPOINT_ID = "6207156555167563776" # text_entity_extraction endpoint diff --git a/samples/snippets/predict_text_sentiment_analysis_sample_test.py b/samples/snippets/predict_text_sentiment_analysis_sample_test.py index e66595b944..b13969224f 100644 --- a/samples/snippets/predict_text_sentiment_analysis_sample_test.py +++ b/samples/snippets/predict_text_sentiment_analysis_sample_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import os + import predict_text_sentiment_analysis_sample ENDPOINT_ID = "7811563922418302976" # sentiment analysis endpoint diff --git a/samples/snippets/upload_model_sample_test.py b/samples/snippets/upload_model_sample_test.py index 7cc9635de6..78943f666e 100644 --- a/samples/snippets/upload_model_sample_test.py +++ b/samples/snippets/upload_model_sample_test.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from uuid import uuid4 + import pytest -import os +import delete_model_sample import helpers - import upload_model_sample -import delete_model_sample PROJECT_ID = os.getenv("BUILD_SPECIFIC_GCLOUD_PROJECT") IMAGE_URI = "gcr.io/cloud-ml-service-public/cloud-ml-online-prediction-model-server-cpu:v1_15py3cmle_op_images_20200229_0210_RC00"