-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: Automl table batch test (#4267)
* added rtest req.txt * samples: added automl batch predict test * added missing package * Update tables/automl/batch_predict_test.py Co-authored-by: Bu Sun Kim <[email protected]> Co-authored-by: Bu Sun Kim <[email protected]>
- Loading branch information
1 parent
8b7cf22
commit 83304cc
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pytest==5.4.2 | ||
pytest==5.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python | ||
|
||
# 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 | ||
# | ||
# http://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 | ||
|
||
from google.cloud.automl_v1beta1.gapic import enums | ||
|
||
import pytest | ||
|
||
import automl_tables_model | ||
import automl_tables_predict | ||
import model_test | ||
|
||
|
||
PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
REGION = "us-central1" | ||
STATIC_MODEL = model_test.STATIC_MODEL | ||
GCS_INPUT = "gs://{}-automl-tables-test/bank-marketing.csv".format(PROJECT) | ||
GCS_OUTPUT = "gs://{}-automl-tables-test/TABLE_TEST_OUTPUT/".format(PROJECT) | ||
|
||
|
||
@pytest.mark.slow | ||
def test_batch_predict(capsys): | ||
ensure_model_online() | ||
automl_tables_predict.batch_predict( | ||
PROJECT, REGION, STATIC_MODEL, GCS_INPUT, GCS_OUTPUT | ||
) | ||
out, _ = capsys.readouterr() | ||
assert "Batch prediction complete" in out | ||
|
||
|
||
def ensure_model_online(): | ||
model = model_test.ensure_model_ready() | ||
if model.deployment_state != enums.Model.DeploymentState.DEPLOYED: | ||
automl_tables_model.deploy_model(PROJECT, REGION, model.display_name) | ||
|
||
return automl_tables_model.get_model(PROJECT, REGION, model.display_name) |