forked from phoenix-oss/llama-stack-mirror
[CLI] remove dependency on CONDA_PREFIX in CLI (#144)
* remove dependency on CONDA_PREFIX in CLI * lint * typo * more robust
This commit is contained in:
parent
fe460ba103
commit
6a8c2ae1df
4 changed files with 26 additions and 20 deletions
|
@ -100,10 +100,7 @@ class StackBuild(Subcommand):
|
||||||
llama_stack_path / "tmp/configs/"
|
llama_stack_path / "tmp/configs/"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
build_dir = (
|
build_dir = DISTRIBS_BASE_DIR / f"llamastack-{build_config.name}"
|
||||||
Path(os.getenv("CONDA_PREFIX")).parent
|
|
||||||
/ f"llamastack-{build_config.name}"
|
|
||||||
)
|
|
||||||
|
|
||||||
os.makedirs(build_dir, exist_ok=True)
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
build_file_path = build_dir / f"{build_config.name}-build.yaml"
|
build_file_path = build_dir / f"{build_config.name}-build.yaml"
|
||||||
|
@ -116,11 +113,6 @@ class StackBuild(Subcommand):
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
cprint(
|
|
||||||
f"Build spec configuration saved at {str(build_file_path)}",
|
|
||||||
color="blue",
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_name = (
|
configure_name = (
|
||||||
build_config.name
|
build_config.name
|
||||||
if build_config.image_type == "conda"
|
if build_config.image_type == "conda"
|
||||||
|
|
|
@ -65,10 +65,19 @@ class StackConfigure(Subcommand):
|
||||||
f"Could not find {build_config_file}. Trying conda build name instead...",
|
f"Could not find {build_config_file}. Trying conda build name instead...",
|
||||||
color="green",
|
color="green",
|
||||||
)
|
)
|
||||||
if os.getenv("CONDA_PREFIX"):
|
if os.getenv("CONDA_PREFIX", ""):
|
||||||
conda_dir = (
|
conda_dir = (
|
||||||
Path(os.getenv("CONDA_PREFIX")).parent / f"llamastack-{args.config}"
|
Path(os.getenv("CONDA_PREFIX")).parent / f"llamastack-{args.config}"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
cprint(
|
||||||
|
"Cannot find CONDA_PREFIX. Trying default conda path ~/.conda/envs...",
|
||||||
|
color="green",
|
||||||
|
)
|
||||||
|
conda_dir = (
|
||||||
|
Path(os.path.expanduser("~/.conda/envs")) / f"llamastack-{args.config}"
|
||||||
|
)
|
||||||
|
|
||||||
build_config_file = Path(conda_dir) / f"{args.config}-build.yaml"
|
build_config_file = Path(conda_dir) / f"{args.config}-build.yaml"
|
||||||
|
|
||||||
if build_config_file.exists():
|
if build_config_file.exists():
|
||||||
|
|
|
@ -92,6 +92,7 @@ def build_image(build_config: BuildConfig, build_file_path: Path):
|
||||||
args = [
|
args = [
|
||||||
script,
|
script,
|
||||||
build_config.name,
|
build_config.name,
|
||||||
|
str(build_file_path),
|
||||||
" ".join(deps),
|
" ".join(deps),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ if [ -n "$LLAMA_MODELS_DIR" ]; then
|
||||||
echo "Using llama-models-dir=$LLAMA_MODELS_DIR"
|
echo "Using llama-models-dir=$LLAMA_MODELS_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$#" -lt 2 ]; then
|
if [ "$#" -lt 3 ]; then
|
||||||
echo "Usage: $0 <distribution_type> <build_name> <pip_dependencies> [<special_pip_deps>]" >&2
|
echo "Usage: $0 <distribution_type> <build_name> <build_file_path> <pip_dependencies> [<special_pip_deps>]" >&2
|
||||||
echo "Example: $0 <distribution_type> mybuild 'numpy pandas scipy'" >&2
|
echo "Example: $0 <distribution_type> mybuild ./my-stack-build.yaml 'numpy pandas scipy'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ set -euo pipefail
|
||||||
|
|
||||||
build_name="$1"
|
build_name="$1"
|
||||||
env_name="llamastack-$build_name"
|
env_name="llamastack-$build_name"
|
||||||
pip_dependencies="$2"
|
build_file_path="$2"
|
||||||
|
pip_dependencies="$3"
|
||||||
|
|
||||||
# Define color codes
|
# Define color codes
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
@ -123,6 +124,9 @@ ensure_conda_env_python310() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mv $build_file_path $CONDA_PREFIX/
|
||||||
|
echo "Build spec configuration saved at $CONDA_PREFIX/$build_name-build.yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_conda_env_python310 "$env_name" "$pip_dependencies" "$special_pip_deps"
|
ensure_conda_env_python310 "$env_name" "$pip_dependencies" "$special_pip_deps"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue