Config: Add override argparser

Add an argparser that casts over to dictionaries of subgroups to
integrate with the config.

This argparser doesn't contain everything in the config due to complexity
issues with CLI args, but will eventually progress to parity. In addition,
it's used to override the config.yml rather than replace it.

A config arg is also provided if the user wants to fully override the
config yaml with another file path.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2024-01-01 14:27:12 -05:00
parent 7176fa66f0
commit bb7a8e4614
4 changed files with 173 additions and 9 deletions

11
main.py
View File

@@ -12,8 +12,10 @@ from functools import partial
from progress.bar import IncrementalBar
import gen_logging
from args import convert_args_to_dict, init_argparser
from auth import check_admin_key, check_api_key, load_auth_keys
from config import (
override_config_from_args,
read_config_from_file,
get_gen_logging_config,
get_model_config,
@@ -493,13 +495,20 @@ async def generate_chat_completion(request: Request, data: ChatCompletionRequest
return response
def entrypoint():
def entrypoint(args: Optional[dict] = None):
"""Entry function for program startup"""
global MODEL_CONTAINER
# Load from YAML config
read_config_from_file(pathlib.Path("config.yml"))
# Parse and override config from args
if args is None:
parser = init_argparser()
args = convert_args_to_dict(parser.parse_args(), parser)
override_config_from_args(args)
network_config = get_network_config()
# Initialize auth keys