Skip to content

Commit

Permalink
use sudo
Browse files Browse the repository at this point in the history
Signed-off-by: harupy <hkawamura0130@gmail.com>
  • Loading branch information
harupy committed Nov 29, 2021
1 parent d4777cf commit fc39ec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 1 addition & 7 deletions tests/conftest.py
@@ -1,5 +1,4 @@
import os
import stat
import inspect
import shutil
from unittest import mock
Expand Down Expand Up @@ -100,11 +99,6 @@ def new_exception(msg, *_, **__):
yield


def on_rm_error(func, path, exc_info): # pylint: disable=unused-argument
os.chmod(path, stat.S_IWRITE)
os.unlink(path)


@pytest.fixture(autouse=True, scope="module")
def clean_up_mlruns_direcotry(request):
"""
Expand All @@ -113,4 +107,4 @@ def clean_up_mlruns_direcotry(request):
yield
mlruns_dir = os.path.join(request.config.rootpath, "mlruns")
if os.path.exists(mlruns_dir):
shutil.rmtree(mlruns_dir, onerror=on_rm_error)
shutil.rmtree(mlruns_dir)
10 changes: 9 additions & 1 deletion tests/projects/test_docker_projects.py
@@ -1,8 +1,8 @@
import os

import pytest
import posixpath # pylint: disable=unused-import
from unittest import mock
import subprocess

from databricks_cli.configure.provider import DatabricksConfig

Expand All @@ -24,6 +24,14 @@
from mlflow.exceptions import MlflowException


@pytest.fixture(autouse=True, scope="module")
def clean_up_mlruns_direcotry(request):
yield
mlruns_dir = os.path.join(request.config.rootpath, "mlruns")
# Use `sudo` to forcibly remove files created in a docker container
subprocess.run(["sudo", "rm", "-rf", mlruns_dir], check=True)


def _build_uri(base_uri, subdirectory):
if subdirectory != "":
return "%s#%s" % (base_uri, subdirectory)
Expand Down

0 comments on commit fc39ec9

Please sign in to comment.