1.8 KiB
1. Install MLflow
Detect this project's Python package manager and add mlflow as a dependency
if it is not already declared:
uv(look foruv.lockor[tool.uv]inpyproject.toml) ->uv add mlflowpoetry(look forpoetry.lock) ->poetry add mlflowpip/ plainrequirements.txt-> appendmlflowandpip install mlflow
Skip this step if mlflow is already a declared dependency.
{{ server_setup }}### 2. Configure tracking URI
Configure MLflow to log to {{ tracking_uri }}. Pick whichever of these fits the
project's conventions:
- Set
MLFLOW_TRACKING_URI={{ tracking_uri }}in the project's env file (.env,.env.example, etc.). - Call
mlflow.set_tracking_uri("{{ tracking_uri }}")once during application startup, before anymlflow.*calls.
Don't do both. If the project already sets a tracking URI, leave it alone and note the existing value in the final summary.
3. Instrument with mlflow.autolog
Consult the instrumenting-with-mlflow-tracing skill in {{ skills_dir }}/ for
the supported libraries and per-integration setup. That skill is the source
of truth for what mlflow.autolog() covers.
For most applications, mlflow.autolog() is the recommended entry point:
import mlflow
mlflow.set_tracking_uri("{{ tracking_uri }}")
mlflow.autolog()
Wire this into the application's entry point(s):
- Find the main entry (e.g.
main.py,app.py,__main__.py, FastAPI lifespan /Depends, Django app configreadyhook, Lambda handler init). - Call
mlflow.autolog()once, before any LLM clients are created. - Do not add it to library modules or tests.
For library-specific instrumentation (LangChain, LangGraph, OpenAI, Anthropic,
LlamaIndex, DSPy, etc.), many libraries have a dedicated
mlflow.<library>.autolog() flavor. The skill above lists them.