diff --git a/packages/google-cloud-automl/samples/beta/requirements.txt b/packages/google-cloud-automl/samples/beta/requirements.txt index 867dfc61e77d..d2157cd180ba 100644 --- a/packages/google-cloud-automl/samples/beta/requirements.txt +++ b/packages/google-cloud-automl/samples/beta/requirements.txt @@ -1 +1 @@ -google-cloud-automl==1.0.1 +google-cloud-automl==2.0.0 diff --git a/packages/google-cloud-automl/samples/beta/video_classification_create_model_test.py b/packages/google-cloud-automl/samples/beta/video_classification_create_model_test.py index f6af031b1c85..148d2d5b7740 100644 --- a/packages/google-cloud-automl/samples/beta/video_classification_create_model_test.py +++ b/packages/google-cloud-automl/samples/beta/video_classification_create_model_test.py @@ -13,36 +13,20 @@ # limitations under the License. import os -import uuid - -from google.cloud import automl_v1beta1 as automl -import pytest import video_classification_create_model PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -DATASET_ID = "VCN510437278078730240" +DATASET_ID = "VCN00000000000000000" OPERATION_ID = None -@pytest.fixture(scope="function", autouse=True) -def teardown(): - yield - - # Cancel the training operation - client = automl.AutoMlClient() - client._transport.operations_client.cancel_operation(OPERATION_ID) - - def test_video_classification_create_model(capsys): - model_name = "test_{}".format(uuid.uuid4()).replace("-", "")[:32] - video_classification_create_model.create_model( - PROJECT_ID, DATASET_ID, model_name - ) - - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - global OPERATION_ID - OPERATION_ID = out.split("Training operation name: ")[1].split("\n")[0] + try: + video_classification_create_model.create_model( + PROJECT_ID, DATASET_ID, "video_class_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/beta/video_object_tracking_create_model_test.py b/packages/google-cloud-automl/samples/beta/video_object_tracking_create_model_test.py index 5844f18f16b8..f966b21db3a5 100644 --- a/packages/google-cloud-automl/samples/beta/video_object_tracking_create_model_test.py +++ b/packages/google-cloud-automl/samples/beta/video_object_tracking_create_model_test.py @@ -13,35 +13,20 @@ # limitations under the License. import os -import uuid - -from google.cloud import automl_v1beta1 as automl -import pytest import video_object_tracking_create_model PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] -DATASET_ID = "VOT2823376535338090496" +DATASET_ID = "VOT00000000000000000000" OPERATION_ID = None -@pytest.fixture(scope="function", autouse=True) -def teardown(): - yield - - # Cancel the training operation - client = automl.AutoMlClient() - client._transport.operations_client.cancel_operation(OPERATION_ID) - - def test_video_classification_create_model(capsys): - model_name = "test_{}".format(uuid.uuid4()).replace("-", "")[:32] - video_object_tracking_create_model.create_model( - PROJECT_ID, DATASET_ID, model_name - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - global OPERATION_ID - OPERATION_ID = out.split("Training operation name: ")[1].split("\n")[0] + try: + video_object_tracking_create_model.create_model( + PROJECT_ID, DATASET_ID, "video_object_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/snippets/language_sentiment_analysis_create_model_test.py b/packages/google-cloud-automl/samples/snippets/language_sentiment_analysis_create_model_test.py index 406f9e1c8aec..12f49e72ed70 100644 --- a/packages/google-cloud-automl/samples/snippets/language_sentiment_analysis_create_model_test.py +++ b/packages/google-cloud-automl/samples/snippets/language_sentiment_analysis_create_model_test.py @@ -14,21 +14,18 @@ import os -import pytest - import language_sentiment_analysis_create_model PROJECT_ID = os.environ["AUTOML_PROJECT_ID"] -DATASET_ID = os.environ["SENTIMENT_ANALYSIS_DATASET_ID"] +DATASET_ID = "TST00000000000000000" -@pytest.mark.slow def test_sentiment_analysis_create_model(capsys): - operation = language_sentiment_analysis_create_model.create_model( - PROJECT_ID, DATASET_ID, "sentiment_test_create_model" - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - operation.cancel() + try: + language_sentiment_analysis_create_model.create_model( + PROJECT_ID, DATASET_ID, "lang_sent_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/snippets/language_text_classification_create_model_test.py b/packages/google-cloud-automl/samples/snippets/language_text_classification_create_model_test.py index 299e328a89e7..995fbc4e20e3 100644 --- a/packages/google-cloud-automl/samples/snippets/language_text_classification_create_model_test.py +++ b/packages/google-cloud-automl/samples/snippets/language_text_classification_create_model_test.py @@ -14,24 +14,18 @@ import os -from google.cloud import automl -import pytest - import language_text_classification_create_model PROJECT_ID = os.environ["AUTOML_PROJECT_ID"] -DATASET_ID = os.environ["TEXT_CLASSIFICATION_DATASET_ID"] +DATASET_ID = "TCN00000000000000000000" -@pytest.mark.slow def test_text_classification_create_model(capsys): - language_text_classification_create_model.create_model( - PROJECT_ID, DATASET_ID, "classification_test_create_model" - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - operation_id = out.split("Training operation name: ")[1].split("\n")[0] - client = automl.AutoMlClient() - client._transport.operations_client.cancel_operation(operation_id) + try: + language_text_classification_create_model.create_model( + PROJECT_ID, DATASET_ID, "lang_text_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/snippets/requirements.txt b/packages/google-cloud-automl/samples/snippets/requirements.txt index 701089adb7c1..aa75e4fbd7cf 100644 --- a/packages/google-cloud-automl/samples/snippets/requirements.txt +++ b/packages/google-cloud-automl/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-translate==2.0.2 +google-cloud-translate==3.0.1 google-cloud-storage==1.31.2 -google-cloud-automl==1.0.1 +google-cloud-automl==2.0.0 diff --git a/packages/google-cloud-automl/samples/snippets/translate_create_model_test.py b/packages/google-cloud-automl/samples/snippets/translate_create_model_test.py index 118c73868e42..f03de69e5bbc 100644 --- a/packages/google-cloud-automl/samples/snippets/translate_create_model_test.py +++ b/packages/google-cloud-automl/samples/snippets/translate_create_model_test.py @@ -14,22 +14,18 @@ import os -from google.cloud import automl - import translate_create_model PROJECT_ID = os.environ["AUTOML_PROJECT_ID"] -DATASET_ID = os.environ["TRANSLATION_DATASET_ID"] +DATASET_ID = "TRL00000000000000000" def test_translate_create_model(capsys): - translate_create_model.create_model( - PROJECT_ID, DATASET_ID, "translate_test_create_model" - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - operation_id = out.split("Training operation name: ")[1].split("\n")[0] - client = automl.AutoMlClient() - client._transport.operations_client.cancel_operation(operation_id) + try: + translate_create_model.create_model( + PROJECT_ID, DATASET_ID, "translate_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/snippets/vision_classification_create_model_test.py b/packages/google-cloud-automl/samples/snippets/vision_classification_create_model_test.py index 76358307c792..46bec0463e8c 100644 --- a/packages/google-cloud-automl/samples/snippets/vision_classification_create_model_test.py +++ b/packages/google-cloud-automl/samples/snippets/vision_classification_create_model_test.py @@ -14,21 +14,18 @@ import os -import pytest - import vision_classification_create_model PROJECT_ID = os.environ["AUTOML_PROJECT_ID"] -DATASET_ID = os.environ["VISION_CLASSIFICATION_DATASET_ID"] +DATASET_ID = "ICN000000000000000000" -@pytest.mark.slow def test_vision_classification_create_model(capsys): - operation = vision_classification_create_model.create_model( - PROJECT_ID, DATASET_ID, "classification_test_create_model" - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - operation.cancel() + try: + vision_classification_create_model.create_model( + PROJECT_ID, DATASET_ID, "classification_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message diff --git a/packages/google-cloud-automl/samples/snippets/vision_object_detection_create_model_test.py b/packages/google-cloud-automl/samples/snippets/vision_object_detection_create_model_test.py index d5379056170e..07ff227ae551 100644 --- a/packages/google-cloud-automl/samples/snippets/vision_object_detection_create_model_test.py +++ b/packages/google-cloud-automl/samples/snippets/vision_object_detection_create_model_test.py @@ -14,21 +14,18 @@ import os -import pytest - import vision_object_detection_create_model PROJECT_ID = os.environ["AUTOML_PROJECT_ID"] -DATASET_ID = os.environ["OBJECT_DETECTION_DATASET_ID"] +DATASET_ID = "IOD0000000000000000" -@pytest.mark.slow def test_vision_object_detection_create_model(capsys): - operation = vision_object_detection_create_model.create_model( - PROJECT_ID, DATASET_ID, "object_test_create_model" - ) - out, _ = capsys.readouterr() - assert "Training started" in out - - # Cancel the operation - operation.cancel() + try: + vision_object_detection_create_model.create_model( + PROJECT_ID, DATASET_ID, "object_test_create_model" + ) + out, _ = capsys.readouterr() + assert "Dataset does not exist." in out + except Exception as e: + assert "Dataset does not exist." in e.message