Skip to content

Commit

Permalink
fix conda env create error dued to read only file system
Browse files Browse the repository at this point in the history
  • Loading branch information
ttapjinda authored and seldondev committed Jun 20, 2020
1 parent 2c27af8 commit abf5570
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions servers/mlflowserver/mlflowserver/conda_env_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import argparse
import json
import yaml
import tempfile
import shutil
from subprocess import run
from seldon_core.microservice import PARAMETERS_ENV_NAME, parse_parameters
from seldon_core import Storage
Expand Down Expand Up @@ -47,6 +49,7 @@ def setup_env(model_folder):
pyfunc_flavour = flavours["python_function"]
env_file_name = pyfunc_flavour["env"]
env_file_path = os.path.join(model_folder, env_file_name)
env_file_path = copy_env(env_file_path)

create_env(env_file_path)
install_base_reqs()
Expand Down Expand Up @@ -107,6 +110,17 @@ def create_env(env_file_path):
run(cmd, shell=True, check=True)


def copy_env(env_file_path):
"""Copy conda.yaml to temp dir
to prevent the case where the existing file is on Read-only file system.
"""
temp_dir = tempfile.mkdtemp()
new_env_path = os.path.join(temp_dir, "conda.yaml")
shutil.copy2(env_file_path, new_env_path)

return new_env_path


def install_base_reqs():
"""Install additional requirements from requirements.txt to existing conda environment
The environment name is read from the `CONDA_ENV_NAME` environment
Expand Down

0 comments on commit abf5570

Please sign in to comment.