|
| 1 | +# Copyright 2021 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 | + |
| 16 | +import create_training_pipeline_text_classification_sample |
| 17 | +import test_constants as constants |
| 18 | + |
| 19 | + |
| 20 | +def test_create_training_pipeline_text_classification_sample( |
| 21 | + mock_sdk_init, |
| 22 | + mock_text_dataset, |
| 23 | + mock_get_automl_text_training_job, |
| 24 | + mock_run_automl_text_training_job, |
| 25 | + mock_get_text_dataset, |
| 26 | +): |
| 27 | + |
| 28 | + create_training_pipeline_text_classification_sample.create_training_pipeline_text_classification_sample( |
| 29 | + project=constants.PROJECT, |
| 30 | + location=constants.LOCATION, |
| 31 | + display_name=constants.DISPLAY_NAME, |
| 32 | + dataset_id=constants.RESOURCE_ID, |
| 33 | + model_display_name=constants.DISPLAY_NAME_2, |
| 34 | + training_fraction_split=constants.TRAINING_FRACTION_SPLIT, |
| 35 | + validation_fraction_split=constants.VALIDATION_FRACTION_SPLIT, |
| 36 | + test_fraction_split=constants.TEST_FRACTION_SPLIT, |
| 37 | + budget_milli_node_hours=constants.BUDGET_MILLI_NODE_HOURS_8000, |
| 38 | + disable_early_stopping=False, |
| 39 | + ) |
| 40 | + |
| 41 | + mock_get_text_dataset.assert_called_once_with(constants.RESOURCE_ID) |
| 42 | + |
| 43 | + mock_sdk_init.assert_called_once_with( |
| 44 | + project=constants.PROJECT, location=constants.LOCATION |
| 45 | + ) |
| 46 | + mock_get_automl_text_training_job.assert_called_once_with( |
| 47 | + display_name=constants.DISPLAY_NAME, |
| 48 | + multi_label=False, |
| 49 | + prediction_type="classification", |
| 50 | + ) |
| 51 | + mock_run_automl_text_training_job.assert_called_once_with( |
| 52 | + dataset=mock_text_dataset, |
| 53 | + model_display_name=constants.DISPLAY_NAME_2, |
| 54 | + training_fraction_split=constants.TRAINING_FRACTION_SPLIT, |
| 55 | + validation_fraction_split=constants.VALIDATION_FRACTION_SPLIT, |
| 56 | + test_fraction_split=constants.TEST_FRACTION_SPLIT, |
| 57 | + budget_milli_node_hours=constants.BUDGET_MILLI_NODE_HOURS_8000, |
| 58 | + disable_early_stopping=False, |
| 59 | + sync=True, |
| 60 | + ) |
0 commit comments