Skip to content
Advertisement

Track to database, artifacts to specific destination

I am running mlflow ui and PostgreSQL db in docker compose.

Mlflow UI container runs like this: mlflow ui --backend-store-uri "postgresql+psycopg2://postgres:passw0rd@database:5432/postgres" --host 0.0.0.0

Then I run my models locally from jupyter, e.g.

remote_server_uri = "postgresql+psycopg2://postgres:passw0rd@localhost:5432/postgres"
mlflow.set_tracking_uri(remote_server_uri)
mlflow.set_experiment("exp2")

X = np.array([-2, -1, 0, 1, 2, 1]).reshape(-1, 1)
y = np.array([0, 0, 1, 1, 1, 0])
lr = LogisticRegression()
lr.fit(X, y)
score = lr.score(X, y)
print("Score: %s" % score)
with mlflow.start_run():
    mlflow.log_metric("score", score)

Everything works fine – experiments get logged into PostgreSQL and mlflow UI can read it from PostgreSQL .

One thing that bothers me is that artifacts are stored locally into ./mlruns folder. How to change it to save it somewhere else?

Advertisement

Answer

So apparently --default-artifact-root argument has to be used when launching server/ui. The only downside is that that default artifact root is relative to development environment, so if you are running mlflow server in docker and specify default-artifact-root to e.g. some/path then the artifacts are going to be saved to your local machine to that path (not inside docker container). Probably the best solution is to use remote storage such as S3/Blob.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement