forked from phoenix-oss/llama-stack-mirror
revert: feat(server): Use system packages for execution (#1551)
Reverts meta-llama/llama-stack#1252 The above PR breaks the following invocation: ```bash llama stack run ~/.llama/distributions/together/together-run.yaml ```
This commit is contained in:
parent
ead9397e22
commit
e13c92f269
2 changed files with 21 additions and 59 deletions
|
@ -56,6 +56,7 @@ class StackRun(Subcommand):
|
||||||
"--env",
|
"--env",
|
||||||
action="append",
|
action="append",
|
||||||
help="Environment variables to pass to the server in KEY=VALUE format. Can be specified multiple times.",
|
help="Environment variables to pass to the server in KEY=VALUE format. Can be specified multiple times.",
|
||||||
|
default=[],
|
||||||
metavar="KEY=VALUE",
|
metavar="KEY=VALUE",
|
||||||
)
|
)
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
|
@ -73,6 +74,7 @@ class StackRun(Subcommand):
|
||||||
type=str,
|
type=str,
|
||||||
help="Image Type used during the build. This can be either conda or container or venv.",
|
help="Image Type used during the build. This can be either conda or container or venv.",
|
||||||
choices=["conda", "container", "venv"],
|
choices=["conda", "container", "venv"],
|
||||||
|
default="conda",
|
||||||
)
|
)
|
||||||
|
|
||||||
def _run_stack_run_cmd(self, args: argparse.Namespace) -> None:
|
def _run_stack_run_cmd(self, args: argparse.Namespace) -> None:
|
||||||
|
@ -118,40 +120,18 @@ class StackRun(Subcommand):
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
self.parser.error(f"failed to parse config file '{config_file}':\n {e}")
|
self.parser.error(f"failed to parse config file '{config_file}':\n {e}")
|
||||||
|
|
||||||
# If neither image type nor image name is provided, assume the server should be run directly
|
|
||||||
# using the current environment packages.
|
|
||||||
if not args.image_type and not args.image_name:
|
|
||||||
logger.info("No image type or image name provided. Assuming environment packages.")
|
|
||||||
from llama_stack.distribution.server.server import main as server_main
|
|
||||||
|
|
||||||
# Build the server args from the current args passed to the CLI
|
|
||||||
server_args = argparse.Namespace()
|
|
||||||
for arg in vars(args):
|
|
||||||
# If this is a function, avoid passing it
|
|
||||||
# "args" contains:
|
|
||||||
# func=<bound method StackRun._run_stack_run_cmd of <llama_stack.cli.stack.run.StackRun object at 0x10484b010>>
|
|
||||||
if callable(getattr(args, arg)):
|
|
||||||
continue
|
|
||||||
setattr(server_args, arg, getattr(args, arg))
|
|
||||||
|
|
||||||
# Run the server
|
|
||||||
server_main(server_args)
|
|
||||||
else:
|
|
||||||
run_args = formulate_run_args(args.image_type, args.image_name, config, template_name)
|
run_args = formulate_run_args(args.image_type, args.image_name, config, template_name)
|
||||||
|
|
||||||
run_args.extend([str(config_file), str(args.port)])
|
run_args.extend([str(config_file), str(args.port)])
|
||||||
if args.disable_ipv6:
|
if args.disable_ipv6:
|
||||||
run_args.append("--disable-ipv6")
|
run_args.append("--disable-ipv6")
|
||||||
|
|
||||||
if args.env:
|
|
||||||
for env_var in args.env:
|
for env_var in args.env:
|
||||||
if "=" not in env_var:
|
if "=" not in env_var:
|
||||||
self.parser.error(f"Environment variable '{env_var}' must be in KEY=VALUE format")
|
self.parser.error(f"Environment variable '{env_var}' must be in KEY=VALUE format")
|
||||||
return
|
|
||||||
key, value = env_var.split("=", 1) # split on first = only
|
key, value = env_var.split("=", 1) # split on first = only
|
||||||
if not key:
|
if not key:
|
||||||
self.parser.error(f"Environment variable '{env_var}' has empty key")
|
self.parser.error(f"Environment variable '{env_var}' has empty key")
|
||||||
return
|
|
||||||
run_args.extend(["--env", f"{key}={value}"])
|
run_args.extend(["--env", f"{key}={value}"])
|
||||||
|
|
||||||
if args.tls_keyfile and args.tls_certfile:
|
if args.tls_keyfile and args.tls_certfile:
|
||||||
|
|
|
@ -17,7 +17,7 @@ import warnings
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from importlib.metadata import version as parse_version
|
from importlib.metadata import version as parse_version
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, List, Optional, Union
|
from typing import Any, List, Union
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from fastapi import Body, FastAPI, HTTPException, Request
|
from fastapi import Body, FastAPI, HTTPException, Request
|
||||||
|
@ -314,17 +314,11 @@ class ClientVersionMiddleware:
|
||||||
return await self.app(scope, receive, send)
|
return await self.app(scope, receive, send)
|
||||||
|
|
||||||
|
|
||||||
def main(args: Optional[argparse.Namespace] = None):
|
def main():
|
||||||
"""Start the LlamaStack server."""
|
"""Start the LlamaStack server."""
|
||||||
parser = argparse.ArgumentParser(description="Start the LlamaStack server.")
|
parser = argparse.ArgumentParser(description="Start the LlamaStack server.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--yaml-config",
|
"--yaml-config",
|
||||||
dest="config",
|
|
||||||
help="(Deprecated) Path to YAML configuration file - use --config instead",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--config",
|
|
||||||
dest="config",
|
|
||||||
help="Path to YAML configuration file",
|
help="Path to YAML configuration file",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -354,20 +348,8 @@ def main(args: Optional[argparse.Namespace] = None):
|
||||||
required="--tls-keyfile" in sys.argv,
|
required="--tls-keyfile" in sys.argv,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Determine whether the server args are being passed by the "run" command, if this is the case
|
|
||||||
# the args will be passed as a Namespace object to the main function, otherwise they will be
|
|
||||||
# parsed from the command line
|
|
||||||
if args is None:
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Check for deprecated argument usage
|
|
||||||
if "--yaml-config" in sys.argv:
|
|
||||||
warnings.warn(
|
|
||||||
"The '--yaml-config' argument is deprecated and will be removed in a future version. Use '--config' instead.",
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
|
|
||||||
if args.env:
|
if args.env:
|
||||||
for env_pair in args.env:
|
for env_pair in args.env:
|
||||||
try:
|
try:
|
||||||
|
@ -378,9 +360,9 @@ def main(args: Optional[argparse.Namespace] = None):
|
||||||
logger.error(f"Error: {str(e)}")
|
logger.error(f"Error: {str(e)}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if args.config:
|
if args.yaml_config:
|
||||||
# if the user provided a config file, use it, even if template was specified
|
# if the user provided a config file, use it, even if template was specified
|
||||||
config_file = Path(args.config)
|
config_file = Path(args.yaml_config)
|
||||||
if not config_file.exists():
|
if not config_file.exists():
|
||||||
raise ValueError(f"Config file {config_file} does not exist")
|
raise ValueError(f"Config file {config_file} does not exist")
|
||||||
logger.info(f"Using config file: {config_file}")
|
logger.info(f"Using config file: {config_file}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue