Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

MLflow runs can be recorded either locally in files or remotely to a tracking server. By default, the MLflow Python API logs runs to files in an mlruns directory wherever you ran your program. You can then the "mlruns" directory which is being created during the execution of the "python train_diabetes.py x.x x.x" in the directory of the code.

~/mlflow/examples/sklearn_elasticnet_diabetes/linux/mlruns

Code Block
languagebash
$ ls ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/

You will see the directory "mlruns" among the others.

In this directory has been created a numerical directory (0, 1, 2, e.t.c.) which has all the results of every execution. In the example we had 3 executions (python train_diabetes.py x.x x.x), so in this numerical directory has been created 3 encrypted directories that correspond to every single execution. Also there is a 4th file which is called "meta.yaml".

Code Block
languagebash
ls ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/mlruns

It returns a number like this... 0

Code Block
languagebash
ls ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/mlruns/0

The return must be something like that...

1f8d0c25da6f4634a31f445a3e2fe987
9514eac210f447e2b2e0c1af7374dcbc
f54784481e294434918dfccd63a24d4d
meta.yaml




Change working directory


To change the default working directory (mlruns) to a custom of our choice, we have to add one more line in the source code. Go to the source file and edit it using a text editor.
For our example the file lives.
$ nano ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/train_diabetes.py
I use "nano" in order to modify the file. You can use any editor you want to modify it (vi is the default terminal editor).

Find the following lines...

import mlflow
import mlflow.sklearn


at the next line add this...

Code Block
languagepy
mlflow.set_tracking_uri('file:myDirectory')

The directory "myDirectory" will be created in the directory of the source file (~/mlflow/examples/sklearn_elasticnet_diabetes/linux/myDirectory) when the source code will executed.


Code Block
languagebash
ls ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/myDirectory/0

# The return must be something like this (as the default working directory)...
1f8d0c25da6f4634a31f445a3e2fe987
9514eac210f447e2b2e0c1af7374dcbc
f54784481e294434918dfccd63a24d4d
meta.yaml




Get the results on the Web Browser


In the directory of the source file that has been also created the directory "mlruns", we can run "mlflow ui" to see the logged runsresults.

Code Block
languagebash
cd ~/mlflow/examples/sklearn_elasticnet_diabetes/linux/
mlflow ui

The return must be something like that...

2020-12-03 14:17:36 +0000] [1267] [INFO] Starting gunicorn 20.0.4
[2020-12-03 14:17:36 +0000] [1267] [INFO] Listening at: http://127.0.0.1:5000 (1267)
[2020-12-03 14:17:36 +0000] [1267] [INFO] Using worker: sync
[2020-12-03 14:17:36 +0000] [1270] [INFO] Booting worker with pid: 1270

NOTICE - When executing "mlflow ui" it looks for the directory "mlruns", if it does not exist then it creates an empty one (only with the file "meta.yaml").


For the custom working directory we have to run...

Code Block
languagebash
mlflow ui --backend-store-uri file:myDirectory \
--default-artifact-root file:myDirectory \
--host 127.0.0.1 \
--port 5000

At the local Web browser URL bar type... 127.0.0.1:5000

NOTE - The command "mlflow ui" should be on run in order to have access at the 127.0.0.1:5000





SSH Tunnel Forwarding


When running "mlruns ui" you can notice the 2nd line of the return, there is the localhost's IP and the port (127.0.0.1:5000) which corresponds to the working directory ("mlruns" as default or anything else we have declared as custom). Now we can use them the IP and the Port to get the results.
Using a remote machine (OpenStack), the instances does do not have a Desktop Environment (GNOME, XFCE, e.t.c.) in order to see the results. But we can check if it has created the "index.html" file at http://127.0.0.1:5000.

Code Block
languagebash
cd ~/Download
wget 127.0.0.1:5000
cat index.html

But, using SSH Tunneling Tunnel Forward we can see the OpenStack's instance localhost results on the local Web browser.

Syntax: ssh -L port:localhost:port userName@FloatingIPinstanceUserName@FloatingIP

Open a new window of the local terminal and type...
Example: ssh -L 5000:localhost127.0.0.1:5000 debian@214.152.131.68
(We can replace the localhost with

NOTE - In this case the user name of Openstack instance is "debian" and the Floating IP 214.152.131.68





Mozilla Firefox modification for the SSH Tunnel Forward


To modify the local Web browser. The following description take place for the Mozilla Firefox.
Preferences -> General -> Scroll down to find "Network Settings" and click the "Settings" button -> "Configure Proxy Access to the Internet" click "No proxy" -> OK
At the local Web browser URL bar type... 127.0.0.1:5000

NOTE - The command "mlflow ui" should be on run in order to have access at the 127.0.0.1:5000





Understanding the files and folders of MLFlow directory by matching the elements of the GUI environment


For cases where there is no GUI for accessing the produced data (when "mlflow ui" cannot be executed). In this case we need to know the folders and the files that the graphical environment uses to extract the data and present them on the screen. This means that, we have to get them manually through their files.
The following image shows the correspondence between files/folders and GUI's elements.


Image Added