latent.mlflow.mlflow_setup¶
MLFlow tracking setup for Prefect flows.
Classes¶
ResolvedTrackingUri¶
Result of tracking URI resolution with its source for diagnostics.
Functions¶
create_latest_symlink¶
Create/update a 'latest' symlink pointing to the most recent MLflow run's outputs.
Creates: data/
Args: flow_name: Name of the flow mlflow_run_id: MLflow run ID to link to
end_mlflow_run¶
End the current MLFlow run and optionally create a 'latest' symlink.
Args:
flow_name: If provided, creates a symlink at data/
log_artifact¶
Log an artifact to MLFlow.
Args: file_path: Path to the file to log artifact_path: Optional subdirectory within the artifact store
log_metrics¶
Log metrics to MLFlow.
Args: metrics: Dictionary of metric name -> value
resolve_tracking_uri¶
Resolve the MLflow tracking URI using a priority chain.
Priority (highest to lowest): 1. mlflow_config from parameters.yaml 2. LATENT_MLFLOW_TRACKING_URI env var 3. MLFLOW_TRACKING_URI env var (standard MLflow convention) 4. TOML config file 5. Default to SQLite backend
Args: mlflow_config: MLflow configuration dict (e.g. from parameters.yaml)
Returns: ResolvedTrackingUri with the URI and its source
setup_mlflow_tracking¶
setup_mlflow_tracking(flow_name: str, run_id: str, parameters: dict | None = None, mlflow_config: dict | None = None, flow_run_name: str | None = None) -> str
Setup MLFlow tracking for a flow run.
Args: flow_name: Name of the flow (used as experiment name) run_id: Prefect run ID (used to link runs) parameters: Flow parameters to log mlflow_config: MLFlow configuration from parameters.yaml
Returns: MLFlow run ID