Skip to content

Commit

Permalink
add pip dependency only if not already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ttapjinda authored and seldondev committed Jun 20, 2020
1 parent a737ae5 commit 830e50a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion servers/mlflowserver/mlflowserver/conda_env_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import json
import yaml
import re
import tempfile
from subprocess import run
from seldon_core.microservice import PARAMETERS_ENV_NAME, parse_parameters
Expand Down Expand Up @@ -78,7 +79,16 @@ def inject_base_reqs(env_file_path):
for dep in conda_env["dependencies"]:
if isinstance(dep, dict) and "pip" in dep:
pip_exists = True
dep["pip"].append(f"-r {BASE_REQS_PATH}")
r = re.compile("=|>|<| ")
package_list = [r.split(p)[0] for p in dep["pip"]]
with open(BASE_REQS_PATH) as f:
for line in f:
line = line.rstrip()
if not line or line.startswith("#"):
continue
package_name = r.split(line)[0]
if package_name not in package_list:
dep["pip"].append(line)
break
if not pip_exists:
new_entry = {"pip": [f"-r {BASE_REQS_PATH}"]}
Expand Down

0 comments on commit 830e50a

Please sign in to comment.