conftest.py
1 import os 2 3 import pytest 4 5 import mlflow 6 7 8 @pytest.fixture(autouse=True) 9 def tracking_uri_mock(tmp_path, monkeypatch): 10 tracking_uri = "sqlite:///{}".format(tmp_path / "mlruns.sqlite") 11 mlflow.set_tracking_uri(tracking_uri) 12 monkeypatch.setenv("MLFLOW_TRACKING_URI", tracking_uri) 13 yield 14 mlflow.set_tracking_uri(None) 15 16 17 @pytest.fixture(autouse=True) 18 def reset_active_experiment_id(): 19 yield 20 mlflow.tracking.fluent._active_experiment_id = None 21 os.environ.pop("MLFLOW_EXPERIMENT_ID", None) 22 23 24 @pytest.fixture(autouse=True) 25 def reset_mlflow_uri(): 26 yield 27 os.environ.pop("MLFLOW_TRACKING_URI", None) 28 os.environ.pop("MLFLOW_REGISTRY_URI", None)