[Python] mlflow cannot fetch model registered on GitLab model registry

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to download artifacts and a model that has been saved using MLflow on GitLab model registry. That's the working part of my code, where I set up the client, create model and version and upload artifact previously saved on a local folder:

    # Running client
    import os
    from mlflow import MlflowClient

    os.environ["MLFLOW_TRACKING_URI"] = "..."
    os.environ["MLFLOW_TRACKING_TOKEN"] = "..."

    client = MlflowClient()

    # Model and version creation
    model_name = 'test_model_n'

    description = 'test model'
    model = client.create_registered_model(model_name, description=description)

    model_version = '1.0.1'
    tags = { "gitlab.version": model_version }
    model_version = client.create_model_version(model_name, model_version, tags=tags)

    # Logging artifacts

    run_id = model_version.run_id
    client.log_artifact(run_id, 'mlartifacts/875771393960734527', artifact_path="")



    Now, in order to fetch the model i tried multiple approaches:

    Method 1


    model_uri = f"models:/{model_name}/{model_version}"
    model = mlflow.pyfunc.load_model(model_uri)



    Download bar reach 100%, but a warning and an error pops out:

    WARNING:urllib3.connectionpool:Connection pool is full, discarding connection: "gitlab server" Connection pool size: 10
    Could not find a registered artifact repository for: c:. Currently registered schemes are: ['', 'file', 's3', 'r2', 'gs', 'wasbs', 'ftp', 'sftp', 'dbfs', 'hdfs', 'viewfs', 'runs', 'models', 'http', 'https', 'mlflow-artifacts', 'abfss']

    Method 2


    artifacts_path, = mlflow.artifacts.download_artifacts(
    run_id=run_id,
    artifact_path="",
    dst_path="./downloaded_model"



    Error:

    ValueError: not enough values to unpack (expected 2, got 1)

    Method 3



    # Se conosci il run_id specifico
    mv = client.get_model_version(model_name, model_version)
    run_id = mv.run_id

    # Costruisci l'URI usando il run_id
    run_uri = f"runs:/{run_id}/[path_to_the_model]"

    model_from_run = mlflow.pyfunc.load_model(run_uri)


    Error:

    ValueError: not enough values to unpack (expected 2, got 1)


    Any help would be very appreciated, feel free to ask for more info if you think it would help.

    Continue reading...

Compartilhe esta Página