Overview
The dbnd-mlflow
plugin allows storing mlflow metrics to DBND tracker together with duplicating them to the mlflow store.
Install
pip install dbnd-mlflow
pip install databand[mlflow]
Config
[core]
databand_url=http://localhost:8080
[mlflow_tracking]
databand_tracking=True
Run example
You might need to install examples at first pip install dbnd-examples
.
dbnd run dbnd_examples.tracking.tracking_mlflow.task_with_mflow
dbnd run dbnd_examples.tracking.tracking_mlflow.task_with_mflow --set-config mlflow_tracking.databand_tracking=True
Explanation
mlflow_example code
from dbnd import task
from mlflow import start_run, end_run
from mlflow import log_metric, log_param
@task
def mlflow_example():
start_run()
log_param("param1", randint(0, 100))
log_param("param2", randint(0, 100))
log_metric("foo1", random())
log_metric("foo2", random())
end_run()
Execution flow:
- Run
dbnd run mlflow_example --set-config mlflow_tracking.databand_tracking=True
- dbnd creates a new dbnd context
dbnd_on_pre_init_context
hook from dbnd_mlflow
is triggered
- a new uri is computed to be used by mlflow, e.g.:
dbnd://localhost:8080?duplicate_tracking_to=http%253A%252F%252Fmlflow-store%253A80%252F
- the new uri is set to be used with
mlflow.set_tracking_uri()
mlflow_example
task starts:
mlflow.start_run()
mlflow
reads entry_points
for each installed package and finds:
- "dbnd = dbnd_mlflow.tracking_store:get_dbnd_store",
- "dbnd+s = dbnd_mlflow.tracking_store:get_dbnd_store",
- "databand = dbnd_mlflow.tracking_store:get_dbnd_store",
- "databand+s = dbnd_mlflow.tracking_store:get_dbnd_store",
mlflow
creates TrackingStoreClient
using the new uri- uri schema instructs to use
dbnd_mlflow.tracking_store:get_dbnd_store
get_dbnd_store
creates dbnd TrackingAPIClient
get_dbnd_store
creates mlflow tracking store to duplicate tracking toget_dbnd_store
returns DatabandStore
instance
log_param()
/log_metric()
- calls to
DatabandStore
- calls to
TrackingAPIClient
- calls to mlflow tracking store to duplicate tracking to
mlflow.end_run()
mlflow_example
endsdbnd_on_exit_context
hook from dbnd_mlflow
is triggered
- restore original mlflow tracking uri