Add startup message
This commit is contained in:
parent
73c6a1a0ec
commit
ec74eb2d6f
3 changed files with 14 additions and 8 deletions
|
|
@ -24,3 +24,5 @@ DEVELOPMENT_TAG_NAME = "development"
|
||||||
ONLINE_TAG_NAME = "online"
|
ONLINE_TAG_NAME = "online"
|
||||||
|
|
||||||
SERVER_NAME = "GreatAI-Server"
|
SERVER_NAME = "GreatAI-Server"
|
||||||
|
|
||||||
|
SE4ML_WEBSITE = 'https://se-ml.github.io/practices/'
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ from pydantic import BaseModel
|
||||||
|
|
||||||
from great_ai.large_file import LargeFile, LargeFileLocal
|
from great_ai.large_file import LargeFile, LargeFileLocal
|
||||||
from great_ai.utilities.logger import get_logger
|
from great_ai.utilities.logger import get_logger
|
||||||
|
import yaml
|
||||||
from .constants import (
|
from .constants import (
|
||||||
DEFAULT_LARGE_FILE_CONFIG_PATHS,
|
DEFAULT_LARGE_FILE_CONFIG_PATHS,
|
||||||
DEFAULT_TRACING_DB_FILENAME,
|
DEFAULT_TRACING_DB_FILENAME,
|
||||||
ENV_VAR_KEY,
|
ENV_VAR_KEY,
|
||||||
PRODUCTION_KEY,
|
PRODUCTION_KEY,
|
||||||
|
SE4ML_WEBSITE,
|
||||||
)
|
)
|
||||||
from .persistence import ParallelTinyDbDriver, TracingDatabaseDriver
|
from .persistence import ParallelTinyDbDriver, TracingDatabaseDriver
|
||||||
|
|
||||||
|
|
@ -59,6 +60,7 @@ def configure(
|
||||||
large_file_implementation: Type[LargeFile] = LargeFileLocal,
|
large_file_implementation: Type[LargeFile] = LargeFileLocal,
|
||||||
should_log_exception_stack: Optional[bool] = None,
|
should_log_exception_stack: Optional[bool] = None,
|
||||||
prediction_cache_size: int = 512,
|
prediction_cache_size: int = 512,
|
||||||
|
disable_se4ml_banner: bool=False
|
||||||
) -> None:
|
) -> None:
|
||||||
global _context
|
global _context
|
||||||
logger = get_logger("great_ai", level=log_level)
|
logger = get_logger("great_ai", level=log_level)
|
||||||
|
|
@ -94,7 +96,14 @@ def configure(
|
||||||
prediction_cache_size=prediction_cache_size,
|
prediction_cache_size=prediction_cache_size,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("Options: configured ✅")
|
logger.info("Setting: configured ✅")
|
||||||
|
for k, v in get_context().to_flat_dict().items():
|
||||||
|
logger.info(f'🔩 {k}: {v}')
|
||||||
|
|
||||||
|
if not is_production and not disable_se4ml_banner:
|
||||||
|
logger.warning(f'You still need to check whether you follow all best practices so that you and others can trust your deployment.')
|
||||||
|
logger.warning(f'> Find out more at {SE4ML_WEBSITE}')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _is_in_production_mode(logger: Optional[Logger]) -> bool:
|
def _is_in_production_mode(logger: Optional[Logger]) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import inspect
|
import inspect
|
||||||
from asyncio.log import logger
|
|
||||||
from functools import lru_cache, partial, wraps
|
from functools import lru_cache, partial, wraps
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
|
@ -41,7 +40,6 @@ from .routes import (
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
class GreatAI(Generic[T]):
|
class GreatAI(Generic[T]):
|
||||||
def __init__(self, func: Callable[..., Any], version: str):
|
def __init__(self, func: Callable[..., Any], version: str):
|
||||||
func = automatically_decorate_parameters(func)
|
func = automatically_decorate_parameters(func)
|
||||||
|
|
@ -72,10 +70,7 @@ class GreatAI(Generic[T]):
|
||||||
redoc_url=None,
|
redoc_url=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(
|
|
||||||
f"Current configuration: {yaml.dump(get_context().to_flat_dict(), stream=None)}"
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deploy(
|
def deploy(
|
||||||
func: Optional[Callable[..., T]] = None,
|
func: Optional[Callable[..., T]] = None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue