scikitplot.mlflow#

scikitplot.mlflow#

MLflow UI | SERVER share the exact same settings.

Adds a project-level configuration mechanism so multiple scripts (e.g., train.py, hpo.py, predict.py) share the exact same MLflow settings, regardless of current working directory.

Examples

Quiskstart Template: Beginner workflow demo

>>> import os
>>> import scikitplot as sp
>>>
>>> # print(sp.mlflow.DEFAULT_PROJECT_MARKERS)
>>> # Walk upward from `start` until a directory containing any marker is found.
>>> # export SCIKITPLOT_PROJECT_MARKERS='[".git","pyproject.toml","README.txt","configs/mlflow.toml"]'
>>> os.environ["SCIKITPLOT_PROJECT_MARKERS"] = (
...     '[".git","pyproject.toml","README.txt","configs/mlflow.toml"]'
... )
>>> sp.mlflow.workflow(
...     profile="local",
...     open_ui_seconds=30,
...     experiment_name="my-first-project",
...     fmt="toml",
...     overwrite=True,  # If config already exists: ./configs/mlflow.toml (use overwrite=True).
... )

CLI

>>> # Walk upward from `start` until a directory containing any marker is found.
>>> # export SCIKITPLOT_PROJECT_MARKERS='[".git","pyproject.toml","README.txt","configs/mlflow.toml"]'
>>> python -m scikitplot.mlflow --profile local --open-ui-seconds 5

User guide. See the MLflow Workflow Automation section for further details.

Cli Helper#

DEFAULT_MLFLOW_SERVER_FLAGS

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

MlflowServerCliCaps

Parsed capability set for mlflow server CLI flags.

ensure_flags_supported

Validate that all long-form CLI flags in args are supported.

get_mlflow_server_cli_caps

Get supported mlflow server flags for the installed MLflow version.

Compat Helper#

import_mlflow

Import MLflow lazily with a user-friendly error.

resolve_download_artifacts

Resolve a canonical artifact download function across MLflow versions.

Config Helper#

_config.

User guide. See the MLflow Workflow Automation section for further details.

ServerConfig

Configuration that maps directly to mlflow server CLI flags.

SessionConfig

Session-level configuration for scikitplot.mlflow.session.

Container Helper#

running_in_docker

Detect whether the current process is running in a Docker container.

Customization Helper#

MlflowProvider

A customizable provider for MLflow-like libraries.

get_provider

Retrieve the currently active MLflow provider.

set_provider

Set the active MLflow provider globally.

use_provider

Temporarily set the MLflow provider for a context block.

Env Helper#

EnvSnapshot

Full snapshot of process environment for strict restoration.

apply_env

Apply .env and explicit overrides to os.environ.

parse_dotenv

Parse a minimal .env file containing KEY=VALUE assignments.

Error Helper#

MlflowCliIncompatibleError

Raised when a requested mlflow server option is not supported by the installed MLflow.

MlflowIntegrationError

Base exception for scikitplot.mlflow errors.

MlflowNotInstalledError

Raised when MLflow is required but not installed.

MlflowServerStartError

Raised when the managed MLflow server fails to start or exits prematurely.

SecurityPolicyViolationError

Raised when an operation is rejected by the active SecurityPolicy.

Facade Helper#

ArtifactsFacade

Artifact helper facade bound to a specific MLflow client/URI.

ModelsFacade

Model helper facade bound to a session-bound MLflow client.

Project Helper#

Project configuration helpers for mlflow.

This module provides two distinct, deterministic responsibilities:

  1. Project root discovery via marker files/directories (e.g., pyproject.toml or .git).

  2. Project-level MLflow config I/O (TOML/YAML) that normalizes local paths so that multiple scripts (train/hpo/predict) behave consistently regardless of current working directory.

Notes

This module intentionally exposes a small public surface for marker customization, while keeping the underlying mutable default private. Users should prefer: - get_project_markers - set_project_markers - project_markers (context manager) - Environment override via SCIKITPLOT_PROJECT_MARKERS (strict JSON list of strings) - Config override via a TOML file containing [project].markers = [...]

Examples

Option A — temporary (best for automation pipelines)

>>> from scikitplot.mlflow._project import project_markers, find_project_root
>>>
>>> with project_markers(["pyproject.toml", ".git", "configs/mlflow.toml"]):
...     root = find_project_root()

Option B — environment (best for CI)

>>> import os
>>>
>>> # Default marker file-folder for auto detection
>>> # Walk upward from `start` until a directory containing any marker is found.
>>> # export SCIKITPLOT_PROJECT_MARKERS='[".git","pyproject.toml","README.txt","configs/mlflow.toml"]'
>>> os.environ["SCIKITPLOT_PROJECT_MARKERS"] = (
...     '[".git","pyproject.toml","README.txt","configs/mlflow.toml"]'
... )

Option C — config-driven (best for teams)

>>> [project]
>>> markers = ["pyproject.toml", ".git", "configs/mlflow.toml"]

User guide. See the MLflow Workflow Automation section for further details.

DEFAULT_PROJECT_MARKERS

Built-in immutable sequence.

ProjectConfig

Project-level configuration for MLflow usage across multiple scripts.

dump_project_config_yaml

Write a ProjectConfig to a YAML file.

ensure_local_store_layout

Ensure local backend/artifact directories exist.

find_project_root

Find a project root directory deterministically.

get_project_markers

Resolve project markers deterministically.

load_project_config

Load project MLflow config from TOML or YAML based on file extension.

load_project_config_toml

Load project MLflow config from a TOML file.

load_project_config_yaml

Load project MLflow config from a YAML file.

normalize_mlflow_store_values

Normalize local store values for consistent multi-script usage.

project_markers

Temporarily override module default markers for a block.

set_project_markers

Set the module default markers.

Readiness Helper#

wait_tracking_ready

Wait until the MLflow tracking REST API responds.

Security Helper#

DEFAULT_SECURITY_POLICY

Declarative security policy for scikitplot.mlflow operations.

RELAXED_SECURITY_POLICY

Declarative security policy for scikitplot.mlflow operations.

SecurityPolicy

Declarative security policy for scikitplot.mlflow operations.

get_security_policy

Return the currently active SecurityPolicy, or None.

security_policy

Temporarily activate a SecurityPolicy for a context block.

set_security_policy

Set the active SecurityPolicy globally.

Server Helper#

SpawnedServer

Spawned MLflow server process state.

build_server_args

Build the CLI args for mlflow server from a ServerConfig.

build_server_command

Build a deterministic mlflow server command.

spawn_server

Spawn an MLflow server subprocess.

Session Helper#

MlflowHandle

A handle that proxies the upstream mlflow module while adding session context.

session

Create a strict, context-managed MLflow session.

session_from_file

Create an MLflow session using a shared project config file (TOML or YAML).

session_from_toml

Create an MLflow session using a shared project TOML config.

Helper#

MlflowVersion

Parsed MLflow version.

is_mlflow_installed

Check whether MLflow is installed in the current Python environment.

mlflow_version

Retrieve the installed MLflow version (if available).

Workflow Helper#

WorkflowPaths

Standardized project config paths used by the workflow.

builtin_config_path

Return the path to the built-in demo config shipped with the package.

default_project_paths

Compute standard config file paths for a project.

export_builtin_config

Export the built-in demo config into the current project.

patch_experiment_name_in_toml

Patch experiment_name = ... in a TOML config deterministically.

run_demo

Run a beginner-friendly end-to-end demo workflow.

workflow

Run the built-in end-to-end MLflow workflow demo.