|
| 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_custom_training_managed_dataset_sample |
| 17 | +import test_constants as constants |
| 18 | + |
| 19 | + |
| 20 | +def test_create_training_pipeline_custom_job_sample( |
| 21 | + mock_sdk_init, |
| 22 | + mock_image_dataset, |
| 23 | + mock_init_custom_training_job, |
| 24 | + mock_run_custom_training_job, |
| 25 | + mock_get_image_dataset, |
| 26 | +): |
| 27 | + |
| 28 | + create_training_pipeline_custom_training_managed_dataset_sample.create_training_pipeline_custom_training_managed_dataset_sample( |
| 29 | + project=constants.PROJECT, |
| 30 | + location=constants.LOCATION, |
| 31 | + display_name=constants.DISPLAY_NAME, |
| 32 | + args=constants.ARGS, |
| 33 | + script_path=constants.SCRIPT_PATH, |
| 34 | + container_uri=constants.CONTAINER_URI, |
| 35 | + model_serving_container_image_uri=constants.CONTAINER_URI, |
| 36 | + dataset_id=constants.RESOURCE_ID, |
| 37 | + model_display_name=constants.DISPLAY_NAME_2, |
| 38 | + replica_count=constants.REPLICA_COUNT, |
| 39 | + machine_type=constants.MACHINE_TYPE, |
| 40 | + accelerator_type=constants.ACCELERATOR_TYPE, |
| 41 | + accelerator_count=constants.ACCELERATOR_COUNT, |
| 42 | + training_fraction_split=constants.TRAINING_FRACTION_SPLIT, |
| 43 | + validation_fraction_split=constants.VALIDATION_FRACTION_SPLIT, |
| 44 | + test_fraction_split=constants.TEST_FRACTION_SPLIT, |
| 45 | + ) |
| 46 | + |
| 47 | + mock_get_image_dataset.assert_called_once_with(constants.RESOURCE_ID) |
| 48 | + |
| 49 | + mock_sdk_init.assert_called_once_with( |
| 50 | + project=constants.PROJECT, location=constants.LOCATION |
| 51 | + ) |
| 52 | + mock_init_custom_training_job.assert_called_once_with( |
| 53 | + display_name=constants.DISPLAY_NAME, |
| 54 | + script_path=constants.SCRIPT_PATH, |
| 55 | + container_uri=constants.CONTAINER_URI, |
| 56 | + model_serving_container_image_uri=constants.CONTAINER_URI, |
| 57 | + ) |
| 58 | + mock_run_custom_training_job.assert_called_once_with( |
| 59 | + dataset=mock_image_dataset, |
| 60 | + model_display_name=constants.DISPLAY_NAME_2, |
| 61 | + args=constants.ARGS, |
| 62 | + replica_count=constants.REPLICA_COUNT, |
| 63 | + machine_type=constants.MACHINE_TYPE, |
| 64 | + accelerator_type=constants.ACCELERATOR_TYPE, |
| 65 | + accelerator_count=constants.ACCELERATOR_COUNT, |
| 66 | + training_fraction_split=constants.TRAINING_FRACTION_SPLIT, |
| 67 | + validation_fraction_split=constants.VALIDATION_FRACTION_SPLIT, |
| 68 | + test_fraction_split=constants.TEST_FRACTION_SPLIT, |
| 69 | + sync=True, |
| 70 | + ) |
0 commit comments