File size: 703 Bytes
8f586ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0a7163
8f586ea
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Repo-wide pytest fixtures.

Pins MLflow's tracking URI to a per-session tmp directory so pipeline tests
don't litter `./mlruns/` in the working tree, and so test runs are isolated
from production MLflow state.
"""
from __future__ import annotations

import os
import tempfile
from pathlib import Path
from typing import Iterator

import pytest


@pytest.fixture(autouse=True, scope="session")
def _isolate_mlflow_tracking_uri() -> Iterator[None]:
    tmp_root = Path(tempfile.mkdtemp(prefix="mlflow_test_"))
    os.environ["MLFLOW_TRACKING_URI"] = tmp_root.as_uri()
    yield
    # Don't rmtree — pytest tmpdir cleanup or OS handles it; rmtree
    # races with mlflow background writes on slow CI.