Exemplo n.º 1
0
def test_get_unique_resource_id_with_invalid_max_length_throws_exception():
    match = "unique resource id must be positive"
    with pytest.raises(ValueError, match=match):
        get_unique_resource_id(max_length=-50)

    with pytest.raises(ValueError, match=match):
        get_unique_resource_id(max_length=0)
Exemplo n.º 2
0
def _get_mlflow_azure_resource_name():
    """
    :return: A unique name for an Azure resource indicating that the resource was created by
             MLflow
    """
    azureml_max_resource_length = 32
    resource_prefix = "mlflow-"
    unique_id = get_unique_resource_id(
        max_length=(azureml_max_resource_length - len(resource_prefix)))
    return resource_prefix + unique_id
Exemplo n.º 3
0
def _get_sagemaker_config_name(endpoint_name):
    return "{en}-config-{uid}".format(en=endpoint_name, uid=get_unique_resource_id())
Exemplo n.º 4
0
def _get_sagemaker_model_name(endpoint_name):
    return "{en}-model-{uid}".format(en=endpoint_name, uid=get_unique_resource_id())
Exemplo n.º 5
0
def test_get_unique_resource_id_with_invalid_max_length_throws_exception():
    with pytest.raises(ValueError):
        get_unique_resource_id(max_length=-50)

    with pytest.raises(ValueError):
        get_unique_resource_id(max_length=0)
Exemplo n.º 6
0
def test_get_unique_resource_id_respects_max_length():
    for max_length in range(5, 30, 5):
        for _ in range(10000):
            assert len(get_unique_resource_id(max_length=max_length)) <= max_length