log_mlflow_chart
log_mlflow_chart(
plot
artifact_file
*
run_id=None
tracking_uri=None
use_cdn=False
)Store an accessible chart in an MLflow run, as an HTML artifact.
The MLflow UI shows an .html artifact in a frame on the run’s Artifacts tab, where the chart is read from the keyboard, as sound, as text and in braille like any other maidr chart.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| plot | Any | The chart: one :func:read_mlflow_metrics returned, or anything :func:maidr.render takes, such as a matplotlib figure or axes. |
required |
| artifact_file | str | Where in the run’s artifacts to store it, ending in .html, such as "charts/loss.html". |
required |
| run_id | str | The run to store it in. By default the active run, as mlflow.log_text would. |
None |
| tracking_uri | str | The tracking server holding run_id. By default MLflow’s own. Used only with run_id. |
None |
| use_cdn | bool, {"auto"}, or None | Where the chart loads maidr.js from. False, the default, stores the script inside the artifact, about 2 MB, so the chart works wherever the tracking server can be reached, with no other network access, and keeps working as maidr.js changes. True loads it from the jsDelivr CDN, which keeps the artifact small. None defers to :func:maidr.get_use_cdn. |
False |
Raises
| Name | Type | Description |
|---|---|---|
| ImportError | If mlflow is not installed. |
|
| ValueError | If artifact_file does not end in .html, which the MLflow UI would show as text. |
Notes
The MLflow UI loads an HTML artifact into a frame sandboxed with allow-scripts alone, so maidr runs in it but cannot keep its settings between visits, and a refreshable braille display cannot be reached from it.
Examples
>>> import mlflow
>>> import maidr
>>> with mlflow.start_run() as run:
... for step, loss in enumerate([0.9, 0.6, 0.4]):
... mlflow.log_metric("loss", loss, step=step)
>>> chart = maidr.read_mlflow_metrics(run.info.run_id)[0]
>>> maidr.log_mlflow_chart(chart, "charts/loss.html", run_id=run.info.run_id)