Skip to content

Commit

Permalink
check if dependency is dict before checking the key
Browse files Browse the repository at this point in the history
  • Loading branch information
ttapjinda authored and seldondev committed Jun 20, 2020
1 parent 4c6cbf0 commit a737ae5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions servers/mlflowserver/mlflowserver/conda_env_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ def inject_base_reqs(env_file_path):
if "dependencies" not in conda_env:
conda_env["dependencies"] = []

dependency = next((dep for dep in conda_env["dependencies"] if "pip" in dep), None)
if dependency is not None:
dependency["pip"].append(f"-r {BASE_REQS_PATH}")
else:
pip_exists = False
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}")
break
if not pip_exists:
new_entry = {"pip": [f"-r {BASE_REQS_PATH}"]}
conda_env["dependencies"].append(new_entry)

Expand Down

0 comments on commit a737ae5

Please sign in to comment.