File size: 1,279 Bytes
ce4bc73
 
 
 
 
 
 
 
 
 
 
 
 
ff73b92
 
 
 
 
 
 
 
 
 
 
 
 
ce4bc73
 
 
 
 
 
 
ff73b92
ce4bc73
 
 
 
ff73b92
 
 
 
 
 
 
 
ce4bc73
 
 
 
 
 
 
 
 
ff73b92
ce4bc73
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Script to start the MLflow UI for viewing model training results.
"""

import argparse
import os
import subprocess
import sys


def main():
    """Start the MLflow UI server"""
    parser = argparse.ArgumentParser(description="Start the MLflow UI server")
    parser.add_argument(
        "--port",
        type=int,
        default=5000,
        help="Port to run the server on (default: 5000)",
    )
    parser.add_argument(
        "--host",
        type=str,
        default="127.0.0.1",
        help="Host to run the server on (default: 127.0.0.1)",
    )
    args = parser.parse_args()

    # Get the project root directory
    script_dir = os.path.dirname(os.path.abspath(__file__))
    project_root = os.path.dirname(script_dir)

    # Set the MLflow tracking URI
    mlruns_dir = os.path.join(project_root, "mlruns")
    tracking_uri = f"file:{mlruns_dir}"

    # Start the MLflow UI
    cmd = [
        "mlflow",
        "ui",
        "--backend-store-uri",
        tracking_uri,
        "--host",
        args.host,
        "--port",
        str(args.port),
    ]

    try:
        subprocess.run(cmd, check=False)
    except KeyboardInterrupt:
        pass
    except Exception:
        sys.exit(1)


if __name__ == "__main__":
    main()