Reputation: 168
I am new to MLflow. I was trying to use it in Jupyter. As part of the quickstart, I ran the following code:
import os
from mlflow import log_metric, log_param, log_artifact
if __name__ == "__main__":
# Log a parameter (key-value pair)
log_param("param1", 5)
# Log a metric; metrics can be updated throughout the run
log_metric("foo", 1)
log_metric("foo", 2)
log_metric("foo", 3)
# Log an artifact (output file)
with open("output.txt", "w") as f:
f.write("Hello world!")
log_artifact("output.txt")
which ran without any problems. However when I then typed in mlflow ui
, I got the error: invalid syntax. What could I be doing wrong?
Upvotes: 3
Views: 11547
Reputation: 351
Maybe a short step by step list for Beginners like me: if you want to run the mlflow ui locally on Jupiter Notebook.
mlflow.start_run()
mlflow ui
, it will return an answer telling you that the ui now runs locally on the local Server 5000!mlflow ui
as explained in the answer above, the cell should run constantly as said aboveUpvotes: 1
Reputation: 586
The Documentation in MLFlow Quickstart assumes that you saved this code as a Python .py
script and run it in Terminal (or other command-line interpreter).
When you run the script, either in Terminal or in Jupyter, a folder named mlruns
is automatically created.
"By default, wherever you run your program, the tracking API writes data into files into an mlruns directory. You can then run MLflow’s Tracking UI"
If you want to run MLflow’s Tracking UI from the Notebook, you should write !mlflow ui
instead of mlflow ui
. You get a syntax error because it is not a valid Python syntax. If you run !mlflow ui
from the Notebook you can still view the Tracking UI at http://localhost:5000. In this case, however, you will not be able to run any other cell, since the current cell keeps running.
You should better use Terminal, and run the code mlflow ui
in the same current working directory as the one that contains your Notebook and the mlruns folder.
Upvotes: 9