mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
rebase
This commit is contained in:
5
main.py
5
main.py
@ -7,19 +7,18 @@ from src.configuration import EnvConf, LogConf, singleton
|
||||
@singleton
|
||||
class Main():
|
||||
env_conf: EnvConf
|
||||
|
||||
@inject
|
||||
def __init__(self, log_config: LogConf, env_conf: EnvConf, log_handler: LogHandler) -> None:
|
||||
self.env_conf=env_conf
|
||||
logging.basicConfig(
|
||||
handlers=[logging.StreamHandler()],
|
||||
handlers=[log_handler],
|
||||
level=log_config.level,
|
||||
datefmt=log_config.time_format,
|
||||
format='%(asctime)s %(message)s')
|
||||
|
||||
def run(self):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("jarvis-models start", extra={"version": "0.0.1"})
|
||||
logger.info("jarvis-models start", "version", "0.0.1")
|
||||
uvicorn.run("server:app", host="0.0.0.0", port=8000, log_level="info")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -36,6 +36,13 @@ class Configuration():
|
||||
if length == 0 or not isinstance(cfg, dict):
|
||||
return None
|
||||
if length == 1:
|
||||
return self.get(path.split("."), cfg, default=default)
|
||||
lenght = len(path)
|
||||
if lenght == 0 or not isinstance(cfg, dict):
|
||||
if default is None:
|
||||
return None
|
||||
return default
|
||||
if lenght == 1:
|
||||
return cfg.get(path[0])
|
||||
return self.get(path[1:], cfg.get(path[0]), default=default)
|
||||
|
||||
@ -87,4 +94,4 @@ class EnvConf():
|
||||
|
||||
@inject
|
||||
def __init__(self, config: Configuration) -> None:
|
||||
self.version = config.get("env.version")
|
||||
self.version = config.get("env.version")
|
||||
Reference in New Issue
Block a user