Skip to content

Commit

Permalink
Prevent clean_up_envs from deleting local development environment (m…
Browse files Browse the repository at this point in the history
…lflow#11249)

Signed-off-by: harupy <[email protected]>
  • Loading branch information
harupy authored and serena-ruan committed Feb 28, 2024
1 parent c3c1e04 commit 533dbb3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import posixpath
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -263,6 +264,9 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):

@pytest.fixture(scope="module", autouse=True)
def clean_up_envs():
"""
Clean up virtualenvs and conda environments created during tests to save disk space.
"""
yield

if "GITHUB_ACTIONS" in os.environ:
Expand All @@ -272,8 +276,11 @@ def clean_up_envs():
if os.name != "nt":
conda_info = json.loads(subprocess.check_output(["conda", "info", "--json"], text=True))
root_prefix = conda_info["root_prefix"]
regex = re.compile(r"mlflow-\w{32,}")
for env in conda_info["envs"]:
if env != root_prefix:
if env == root_prefix:
continue
if regex.fullmatch(os.path.basename(env)):
shutil.rmtree(env, ignore_errors=True)


Expand Down

0 comments on commit 533dbb3

Please sign in to comment.