mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
fix docker configure
This commit is contained in:
parent
5ec64ac68c
commit
f5d5e32d62
1 changed files with 45 additions and 29 deletions
|
@ -53,46 +53,62 @@ class StackConfigure(Subcommand):
|
||||||
from termcolor import cprint
|
from termcolor import cprint
|
||||||
|
|
||||||
docker_image = None
|
docker_image = None
|
||||||
|
|
||||||
|
build_config_file = Path(args.config)
|
||||||
|
|
||||||
|
if build_config_file.exists():
|
||||||
|
with open(build_config_file, "r") as f:
|
||||||
|
build_config = BuildConfig(**yaml.safe_load(f))
|
||||||
|
self._configure_llama_distribution(build_config, args.output_dir)
|
||||||
|
return
|
||||||
|
|
||||||
|
# if we get here, we need to try to find the conda build config file
|
||||||
|
cprint(
|
||||||
|
f"Could not find {build_config_file}. Trying conda build name instead...",
|
||||||
|
color="green",
|
||||||
|
)
|
||||||
conda_dir = Path(os.getenv("CONDA_PREFIX")).parent / f"llamastack-{args.config}"
|
conda_dir = Path(os.getenv("CONDA_PREFIX")).parent / 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 not build_config_file.exists():
|
if build_config_file.exists():
|
||||||
cprint(
|
with open(build_config_file, "r") as f:
|
||||||
f"Could not find {build_config_file}. Trying docker image name instead...",
|
build_config = BuildConfig(**yaml.safe_load(f))
|
||||||
color="green",
|
|
||||||
)
|
|
||||||
docker_image = args.config
|
|
||||||
|
|
||||||
builds_dir = BUILDS_BASE_DIR / ImageType.docker.value
|
self._configure_llama_distribution(build_config, args.output_dir)
|
||||||
if args.output_dir:
|
return
|
||||||
builds_dir = Path(output_dir)
|
|
||||||
os.makedirs(builds_dir, exist_ok=True)
|
|
||||||
|
|
||||||
script = pkg_resources.resource_filename(
|
# if we get here, we need to try to find the docker image
|
||||||
"llama_stack", "distribution/configure_container.sh"
|
cprint(
|
||||||
)
|
f"Could not find {build_config_file}. Trying docker image name instead...",
|
||||||
script_args = [script, docker_image, str(builds_dir)]
|
color="green",
|
||||||
|
)
|
||||||
|
docker_image = args.config
|
||||||
|
builds_dir = BUILDS_BASE_DIR / ImageType.docker.value
|
||||||
|
if args.output_dir:
|
||||||
|
builds_dir = Path(output_dir)
|
||||||
|
os.makedirs(builds_dir, exist_ok=True)
|
||||||
|
|
||||||
return_code = run_with_pty(script_args)
|
script = pkg_resources.resource_filename(
|
||||||
|
"llama_stack", "distribution/configure_container.sh"
|
||||||
|
)
|
||||||
|
script_args = [script, docker_image, str(builds_dir)]
|
||||||
|
|
||||||
# we have regenerated the build config file with script, now check if it exists
|
return_code = run_with_pty(script_args)
|
||||||
if return_code != 0:
|
|
||||||
self.parser.error(
|
|
||||||
f"Can not find {build_config_file}. Please run llama stack build first or check if docker image exists"
|
|
||||||
)
|
|
||||||
|
|
||||||
build_name = docker_image.removeprefix("llamastack-")
|
# we have regenerated the build config file with script, now check if it exists
|
||||||
saved_file = str(builds_dir / f"{build_name}-run.yaml")
|
if return_code != 0:
|
||||||
cprint(
|
self.parser.error(
|
||||||
f"YAML configuration has been written to {saved_file}. You can now run `llama stack run {saved_file}`",
|
f"Failed to configure container {docker_image} with return code {return_code}. Please run `llama stack build first`. "
|
||||||
color="green",
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(build_config_file, "r") as f:
|
build_name = docker_image.removeprefix("llamastack-")
|
||||||
build_config = BuildConfig(**yaml.safe_load(f))
|
saved_file = str(builds_dir / f"{build_name}-run.yaml")
|
||||||
|
cprint(
|
||||||
self._configure_llama_distribution(build_config, args.output_dir)
|
f"YAML configuration has been written to {saved_file}. You can now run `llama stack run {saved_file}`",
|
||||||
|
color="green",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
def _configure_llama_distribution(
|
def _configure_llama_distribution(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue