Args: Add subcommands to run actions
Migrate OpenAPI and sample config export to subcommands "export-openapi" and "export-config". Also add a "download" subcommand that passes args to the TabbyAPI downloader. This allows models to be downloaded via the API and CLI args. Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
parent
30f02e5453
commit
30ab8e04b9
6 changed files with 112 additions and 31 deletions
18
main.py
18
main.py
|
|
@ -1,5 +1,6 @@
|
|||
"""The main tabbyAPI module. Contains the FastAPI server and endpoints."""
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import os
|
||||
import pathlib
|
||||
|
|
@ -11,7 +12,7 @@ from typing import Optional
|
|||
from common import gen_logging, sampling, model
|
||||
from common.args import convert_args_to_dict, init_argparser
|
||||
from common.auth import load_auth_keys
|
||||
from common.actions import branch_to_actions
|
||||
from common.actions import run_subcommand
|
||||
from common.logger import setup_logger
|
||||
from common.networking import is_port_in_use
|
||||
from common.signals import signal_handler
|
||||
|
|
@ -99,7 +100,10 @@ async def entrypoint_async():
|
|||
await start_api(host, port)
|
||||
|
||||
|
||||
def entrypoint(arguments: Optional[dict] = None):
|
||||
def entrypoint(
|
||||
args: Optional[argparse.Namespace] = None,
|
||||
parser: Optional[argparse.ArgumentParser] = None,
|
||||
):
|
||||
setup_logger()
|
||||
|
||||
# Set up signal aborting
|
||||
|
|
@ -115,15 +119,17 @@ def entrypoint(arguments: Optional[dict] = None):
|
|||
install()
|
||||
|
||||
# Parse and override config from args
|
||||
if arguments is None:
|
||||
if args is None:
|
||||
parser = init_argparser()
|
||||
arguments = convert_args_to_dict(parser.parse_args(), parser)
|
||||
args = parser.parse_args()
|
||||
|
||||
dict_args = convert_args_to_dict(args, parser)
|
||||
|
||||
# load config
|
||||
config.load(arguments)
|
||||
config.load(dict_args)
|
||||
|
||||
# branch to default paths if required
|
||||
if branch_to_actions():
|
||||
if run_subcommand(args):
|
||||
return
|
||||
|
||||
# Check exllamav2 version and give a descriptive error if it's too old
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue