mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-28 18:21:42 +00:00
fix command line args
- move to a complet class singleton to avoid propagation errors - remove legacy load confing precedure
This commit is contained in:
@@ -16,7 +16,10 @@ class TabbyConfig:
|
|||||||
developer: dict = {}
|
developer: dict = {}
|
||||||
embeddings: dict = {}
|
embeddings: dict = {}
|
||||||
|
|
||||||
def __init__(self, arguments: Optional[dict] = None):
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def load_config(self, arguments: Optional[dict] = None):
|
||||||
"""load the global application config"""
|
"""load the global application config"""
|
||||||
|
|
||||||
# config is applied in order of items in the list
|
# config is applied in order of items in the list
|
||||||
@@ -44,10 +47,10 @@ class TabbyConfig:
|
|||||||
with open(str(config_path.resolve()), "r", encoding="utf8") as config_file:
|
with open(str(config_path.resolve()), "r", encoding="utf8") as config_file:
|
||||||
return unwrap(yaml.safe_load(config_file), {})
|
return unwrap(yaml.safe_load(config_file), {})
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.info("The config.yml file cannot be found")
|
logger.info(f"The '{config_path.name}' file cannot be found")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(
|
logger.error(
|
||||||
"The YAML config couldn't load because of "
|
f"The YAML config from '{config_path.name}' couldn't load because of "
|
||||||
f"the following error:\n\n{exc}"
|
f"the following error:\n\n{exc}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -86,11 +89,3 @@ class TabbyConfig:
|
|||||||
|
|
||||||
# Create an empty instance of the shared var to make sure nothing breaks
|
# Create an empty instance of the shared var to make sure nothing breaks
|
||||||
config: TabbyConfig = TabbyConfig()
|
config: TabbyConfig = TabbyConfig()
|
||||||
|
|
||||||
|
|
||||||
def load_config(arguments: dict):
|
|
||||||
"""Load a populated config class on startup."""
|
|
||||||
|
|
||||||
global shared_config
|
|
||||||
|
|
||||||
shared_config = TabbyConfig(arguments)
|
|
||||||
|
|||||||
6
main.py
6
main.py
@@ -15,7 +15,7 @@ from common.auth import load_auth_keys
|
|||||||
from common.logger import setup_logger
|
from common.logger import setup_logger
|
||||||
from common.networking import is_port_in_use
|
from common.networking import is_port_in_use
|
||||||
from common.signals import signal_handler
|
from common.signals import signal_handler
|
||||||
from common.tabby_config import config, load_config
|
from common.tabby_config import config
|
||||||
from common.utils import unwrap
|
from common.utils import unwrap
|
||||||
from endpoints.server import export_openapi, start_api
|
from endpoints.server import export_openapi, start_api
|
||||||
from endpoints.utils import do_export_openapi
|
from endpoints.utils import do_export_openapi
|
||||||
@@ -110,7 +110,7 @@ def entrypoint(arguments: Optional[dict] = None):
|
|||||||
arguments = convert_args_to_dict(parser.parse_args(), parser)
|
arguments = convert_args_to_dict(parser.parse_args(), parser)
|
||||||
|
|
||||||
# load config
|
# load config
|
||||||
load_config(arguments)
|
config.load_config(arguments)
|
||||||
|
|
||||||
if do_export_openapi:
|
if do_export_openapi:
|
||||||
openapi_json = export_openapi()
|
openapi_json = export_openapi()
|
||||||
@@ -123,7 +123,7 @@ def entrypoint(arguments: Optional[dict] = None):
|
|||||||
|
|
||||||
# Check exllamav2 version and give a descriptive error if it's too old
|
# Check exllamav2 version and give a descriptive error if it's too old
|
||||||
# Skip if launching unsafely
|
# Skip if launching unsafely
|
||||||
|
print(f"MAIN.PY {config=}")
|
||||||
if unwrap(config.developer.get("unsafe_launch"), False):
|
if unwrap(config.developer.get("unsafe_launch"), False):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"UNSAFE: Skipping ExllamaV2 version check.\n"
|
"UNSAFE: Skipping ExllamaV2 version check.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user