AlexBarbier/mlflow-tracking-server
0
1import os2import mlflow3from mlflow import log_metric, log_param, log_artifacts4from random import random, randint5 6# Set tracking URI to your Hugging Face application7mlflow.set_tracking_uri(os.environ["APP_URI"])8 9if __name__ == "__main__":10 # Log a parameter (key-value pair)11 log_param("param1", randint(0, 100))12 13 # Log a metric; metrics can be updated throughout the run14 log_metric("foo", random())15 log_metric("foo", random() + 1)16 log_metric("foo", random() + 2)17 18 # Log an artifact (output file)19 if not os.path.exists("outputs"):20 os.makedirs("outputs")21 with open("outputs/test.txt", "w") as f:22 f.write("hello world!")23 log_artifacts("outputs")