mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-12 04:50:39 +00:00
feat: add --log-level to llama stack
logcat uses logging.INFO unless an environment variable is properly read in. Allow the user to pass `--log-level` with one of the valid stringified logging levels at run time Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
af396e3809
commit
b5818d1ea7
6 changed files with 30 additions and 7 deletions
|
@ -183,10 +183,11 @@ Now, let's start the Llama Stack Distribution Server. You will need the YAML con
|
|||
|
||||
```
|
||||
llama stack run -h
|
||||
usage: llama stack run [-h] [--port PORT] [--image-name IMAGE_NAME] [--disable-ipv6] [--env KEY=VALUE] [--tls-keyfile TLS_KEYFILE]
|
||||
[--tls-certfile TLS_CERTFILE] [--image-type {conda,container,venv}]
|
||||
usage: llama stack run [-h] [--port PORT] [--image-name IMAGE_NAME] [--disable-ipv6] [--env KEY=VALUE] [--tls-keyfile TLS_KEYFILE] [--tls-certfile TLS_CERTFILE]
|
||||
[--image-type {conda,container,venv}]
|
||||
config
|
||||
|
||||
|
||||
Start the server for a Llama Stack Distribution. You should have already built (or downloaded) and configured the distribution.
|
||||
|
||||
positional arguments:
|
||||
|
|
|
@ -212,7 +212,7 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
|
|||
config_dict = yaml.safe_load(run_config.read_text())
|
||||
config = parse_and_maybe_upgrade_config(config_dict)
|
||||
run_args = formulate_run_args(args.image_type, args.image_name, config, args.template)
|
||||
run_args.extend([run_config, str(os.getenv("LLAMA_STACK_PORT", 8321))])
|
||||
run_args.extend([run_config, str(os.getenv("LLAMA_STACK_PORT", 8321)), "info"])
|
||||
run_with_pty(run_args)
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ class StackRun(Subcommand):
|
|||
|
||||
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), str(args.log_level)])
|
||||
print(run_args)
|
||||
if args.disable_ipv6:
|
||||
run_args.append("--disable-ipv6")
|
||||
|
||||
|
|
|
@ -32,6 +32,14 @@ class StackParser(Subcommand):
|
|||
version=f"{version('llama-stack')}",
|
||||
)
|
||||
|
||||
self.parser.add_argument(
|
||||
"--log-level",
|
||||
type=str,
|
||||
choices=["debug", "info", "warning", "critical", "error"],
|
||||
default="info",
|
||||
help="Log level for the stack to use.",
|
||||
)
|
||||
|
||||
self.parser.set_defaults(func=lambda args: self.parser.print_help())
|
||||
|
||||
subparsers = self.parser.add_subparsers(title="stack_subcommands")
|
||||
|
|
|
@ -313,8 +313,6 @@ class ClientVersionMiddleware:
|
|||
|
||||
|
||||
def main():
|
||||
logcat.init()
|
||||
|
||||
"""Start the LlamaStack server."""
|
||||
parser = argparse.ArgumentParser(description="Start the LlamaStack server.")
|
||||
parser.add_argument(
|
||||
|
@ -347,9 +345,20 @@ def main():
|
|||
help="Path to TLS certificate file for HTTPS",
|
||||
required="--tls-keyfile" in sys.argv,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--log-level",
|
||||
type=str,
|
||||
choices=["debug", "info", "warning", "critical", "error"],
|
||||
default="info",
|
||||
help="Log level for the running server to use.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# convert info, debug, warning, critical, or error to valid logging level
|
||||
log_level = logging._nameToLevel.get(args.log_level.upper(), logging.INFO)
|
||||
logcat.init(default_level=log_level)
|
||||
|
||||
if args.env:
|
||||
for env_pair in args.env:
|
||||
try:
|
||||
|
|
|
@ -27,7 +27,7 @@ error_handler() {
|
|||
trap 'error_handler ${LINENO}' ERR
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 <env_type> <env_path_or_name> <yaml_config> <port> <script_args...>"
|
||||
echo "Usage: $0 <env_type> <env_path_or_name> <yaml_config> <port> <log_level> <script_args...>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -44,6 +44,9 @@ shift
|
|||
port="$1"
|
||||
shift
|
||||
|
||||
log_level="$1"
|
||||
shift
|
||||
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||
source "$SCRIPT_DIR/common.sh"
|
||||
|
||||
|
@ -103,6 +106,7 @@ if [[ "$env_type" == "venv" || "$env_type" == "conda" ]]; then
|
|||
$PYTHON_BINARY -m llama_stack.distribution.server.server \
|
||||
--yaml-config "$yaml_config" \
|
||||
--port "$port" \
|
||||
--log-level "$log_level" \
|
||||
$env_vars \
|
||||
$other_args
|
||||
elif [[ "$env_type" == "container" ]]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue