def test_deploy_tf_exporter_path(self, mock_set_default_version, mock_create_version, mock_create_model, mock_storage_client): mock_storage_client().get_bucket().list_blobs().prefixes = [ 'uri/export/exporter/123' ] mock_create_model.return_value = { 'name': 'projects/mock-project/models/mock-model' } expected_version = { 'name': 'projects/mock-project/models/mock-model/version/mock-version' } mock_create_version.return_value = expected_version result = deploy('gs://model/uri', 'mock-project') self.assertEqual(expected_version, result) mock_create_version.assert_called_with( 'projects/mock-project/models/mock-model', 'gs://model/uri/export/exporter/123', None, # version_name None, # runtime_version None, # python_version None, # version False, # replace_existing_version 30)
def test_deploy_tf_exporter_path(self, mock_set_default_version, mock_create_version, mock_create_model, mock_storage_client): prefixes_mock = mock.PropertyMock() prefixes_mock.side_effect = [ set(['uri/export/exporter/']), set(['uri/export/exporter/123']), ] type(mock_storage_client().bucket().list_blobs()).prefixes = prefixes_mock mock_storage_client().bucket().list_blobs().__iter__.return_value = [] mock_storage_client().bucket().name = 'model' mock_create_model.return_value = { 'name': 'projects/mock-project/models/mock-model' } expected_version = { 'name': 'projects/mock-project/models/mock-model/version/mock-version' } mock_create_version.return_value = expected_version result = deploy('gs://model/uri', 'mock-project') self.assertEqual(expected_version, result) mock_create_version.assert_called_with( 'projects/mock-project/models/mock-model', 'gs://model/uri/export/exporter/123', None, # version_name None, # runtime_version None, # python_version None, # version False, # replace_existing_version 30)
def test_deploy_set_default_version(self, mock_set_default_version, mock_create_version, mock_create_model, mock_storage_client): mock_storage_client().bucket().list_blobs().prefixes = [] mock_storage_client().bucket().list_blobs().__iter__.return_value = [] mock_create_model.return_value = { 'name': 'projects/mock-project/models/mock-model' } expected_version = { 'name': 'projects/mock-project/models/mock-model/version/mock-version' } mock_create_version.return_value = expected_version mock_set_default_version.return_value = expected_version result = deploy( 'gs://model/uri', 'mock-project', set_default=True, model_uri_output_path='/tmp/kfp/output/ml_engine/model_uri.txt', model_name_output_path='/tmp/kfp/output/ml_engine/model_name.txt', version_name_output_path= '/tmp/kfp/output/ml_engine/version_name.txt', ) self.assertEqual(expected_version, result) mock_set_default_version.assert_called_with( 'projects/mock-project/models/mock-model/version/mock-version')
def test_deploy_set_default_version(self, mock_set_default_version, mock_create_version, mock_create_model, mock_storage_client): mock_storage_client().get_bucket().list_blobs().prefixes = [] mock_create_model.return_value = { 'name': 'projects/mock-project/models/mock-model' } expected_version = { 'name': 'projects/mock-project/models/mock-model/version/mock-version' } mock_create_version.return_value = expected_version mock_set_default_version.return_value = expected_version result = deploy('gs://model/uri', 'mock-project', set_default=True) self.assertEqual(expected_version, result) mock_set_default_version.assert_called_with( 'projects/mock-project/models/mock-model/version/mock-version')
def test_deploy_tf_exporter_path(self, mock_set_default_version, mock_create_version, mock_create_model, mock_storage_client): prefixes_mock = mock.PropertyMock() prefixes_mock.return_value = set(['uri/012/', 'uri/123/']) type(mock_storage_client().bucket().list_blobs() ).prefixes = prefixes_mock mock_storage_client().bucket().list_blobs().__iter__.return_value = [] mock_storage_client().bucket().name = 'model' mock_create_model.return_value = { 'name': 'projects/mock-project/models/mock-model' } expected_version = { 'name': 'projects/mock-project/models/mock-model/version/mock-version' } mock_create_version.return_value = expected_version result = deploy( 'gs://model/uri', 'mock-project', model_uri_output_path='/tmp/kfp/output/ml_engine/model_uri.txt', model_name_output_path='/tmp/kfp/output/ml_engine/model_name.txt', version_name_output_path= '/tmp/kfp/output/ml_engine/version_name.txt', ) self.assertEqual(expected_version, result) mock_create_version.assert_called_with( 'projects/mock-project/models/mock-model', 'gs://model/uri/123/', None, # version_name None, # runtime_version None, # python_version None, # version False, # replace_existing_version 30, version_name_output_path= '/tmp/kfp/output/ml_engine/version_name.txt', )