in src/responsibleai/rai_analyse/rai_component_utilities.py [0:0]
def install(self):
try:
if self.use_separate_conda_env:
# generate some random characters to add to model path
random_chars = str(uuid.uuid4())[:8]
tmp_model_path = "./mlflow_model" + random_chars
model_path = self.model_path
if (not model_path and self.model_id):
model_path = Model.get_model_path(model_name=self.model.name,
version=self.model.version)
shutil.copytree(model_path, tmp_model_path)
model_uri = tmp_model_path
_logger.info("MODEL URI: {}".format(
model_uri
))
for root, _, files in os.walk(model_uri):
for f in files:
full_path = os.path.join(root, f)
_logger.info("FILE: {}".format(
full_path
))
conda_install_command = ["mlflow", "models", "prepare-env",
"-m", model_uri,
"--env-manager", "conda"]
else:
# mlflow model input mount as read only. Conda need write access.
local_conda_dep = "./conda_dep.yaml"
shutil.copyfile(self.conda_file, local_conda_dep)
conda_prefix = str(pathlib.Path(sys.executable).parents[1])
conda_install_command = ["conda", "env", "update",
"--prefix", conda_prefix,
"-f", local_conda_dep]
install_log = subprocess.check_output(conda_install_command)
_logger.info(
"Conda dependency installation successful, logs: {}".format(
install_log
)
)
except subprocess.CalledProcessError as e:
_logger.error(
"Installing dependency using conda.yaml from mlflow model failed: {}".format(
e.output
)
)
_classify_and_log_pip_install_error(e.output)
raise e
return