Beispiel #1
0
def test_is_local_date_updated_true(mocker):
    model_name = "model_name"
    model_date = "model_date"
    mocker.patch.object(Minio, 'list_buckets')
    mocker.patch.object(ICEDLStore,
                        "_get_cache",
                        return_value={model_name: model_date})
    ice_dl_manager = ICEDLStore()
    bool_value = ice_dl_manager._is_local_date_updated(model_name, model_date)
    assert bool_value == True
Beispiel #2
0
def test_create_config_files_dict(mocker):
    mocker.MagicMock(Minio)
    mocker.patch.object(Minio, 'list_buckets')
    config_file_list = ['path/file1', 'path/file2', 'path/file3', 'path/file4']
    model_param_dict = {
        "model_config_documents": {
            "data_file": "file1",
            "conf_file": "file2",
            "conf_file": "file2",
            "weight_file": "file3",
            "names_file": "file4"
        }
    }
    ice_dl_manager = ICEDLStore()
    config_files_dict = ice_dl_manager._create_config_files_dict(
        config_file_list, model_param_dict)
    assert isinstance(config_files_dict, dict)
Beispiel #3
0
def test_get_model_files_from_minio(mocker):
    """

    :param mocker:
    :return:
    """
    mocker.patch.object(Minio, 'list_buckets')
    ice_dl_manager = ICEDLStore()
    model_name = "model_name"
    mocker.patch.object(ICEDLStore, "_check_bucket")
    mocker.patch.object(Minio, 'list_objects')
    mocker.patch.object(Minio, 'get_object')
    mocker.patch.object(ICEDLStore,
                        '_store_model_files_in_local',
                        return_value=[])
    file_paths = ice_dl_manager._get_model_files_from_minio(model_name)
    ice_dl_manager._check_bucket.assert_called_once_with(model_name)
    assert isinstance(file_paths, list)
Beispiel #4
0
def test_check_model_config_files_name_same_files(mocker):
    mocker.MagicMock(Minio)
    mocker.patch.object(Minio, 'list_buckets')
    model_param_dict = {
        "model_name": "invoice-extraction",
        "model_class": "models.invoice_extraction.InvoiceModel.InvoiceModel",
        "prediction_status": "prediction_failed",
        "prediction_status_message": "Incorrect padding",
        "model_config_documents": {
            "data_file": "name1"
        }
    }
    object_minio = Object(bucket_name="",
                          object_name="name1",
                          last_modified="",
                          etag="",
                          size=0)

    mocker.patch.object(Minio, 'list_objects', return_value=[object_minio])
    ice_dl_manager = ICEDLStore()
    mocker.patch.object(ice_dl_manager, 'raise_exception')
    ice_dl_manager._check_model_config_files_names(model_param_dict)
    ice_dl_manager.raise_exception.assert_not_called()
Beispiel #5
0
def test_get_cache(mocker):
    mocker.patch.object(Minio, 'list_buckets')
    ice_dl_manager = ICEDLStore()
    cache = ice_dl_manager._get_cache()
    assert isinstance(cache, diskcache.Cache)
Beispiel #6
0
def test_get_buckets(mocker):
    mocker.patch.object(Minio, 'list_buckets')
    ice_dl_manager = ICEDLStore()
    bukets = ice_dl_manager._get_buckets()
    assert ice_dl_manager.connection.list_buckets.call_count == 2
    assert isinstance(bukets, list)