pythonmlflowmlops

MLflow - How to point interface path to show the expected result


I just started MLflow today and fail to display the log result on MLflow ui interface. Will appreciate a lot if someone can give me some hint..

tried the sample code below

import os
from random import random, randint
from mlflow import log_metric, log_param, log_artifacts

if __name__ == "__main__":
    # Log a parameter (key-value pair)
    log_param("param1", randint(0, 100))

    # Log a metric; metrics can be updated throughout the run
    log_metric("foo", random())
    log_metric("foo", random() + 1)
    log_metric("foo", random() + 2)

    # Log an artifact (output file)
    if not os.path.exists("outputs"):
        os.makedirs("outputs")
    with open("outputs/test.txt", "w") as f:
        f.write("hello world!")
    log_artifacts("outputs")

ran the script above for 3 times and it gave me the result in the following structure. 3 folders representing 3 runs separately:

file:///home/devuser/project/mlruns/0
0 - 0737fec7d4824384b6320070cd688b78
    355d57e092a242b7aa263451d280b497 
    ed2614ffe2fd4f2db991d5d7166635f8  
    meta.yaml

with folders/files artifacts, meta.yaml, metrics, params, tags in each folder separately.

I ran mlflow ui under file:///home/devuser/project/mlruns/ but nothing was showed on the interface. tried to look this up but no one has come across this problem with this kind of simple code.

Appreciate a lot if someone could kindly let me know how I can change my setting.. Thank you..


Solution

  • You need to run mlflow ui in the project directory itself, not inside the mlruns - if you look into the documentation for mlflow ui command, it says:

    --default-artifact-root <URI>

    Path to local directory to store artifacts, for new experiments. Note that this flag does not impact already-created experiments. Default: ./mlruns