Add startup message

This commit is contained in:
Andras Schmelczer 2022-06-22 15:10:36 +02:00
parent 73c6a1a0ec
commit ec74eb2d6f
3 changed files with 14 additions and 8 deletions

View file

@ -24,3 +24,5 @@ DEVELOPMENT_TAG_NAME = "development"
ONLINE_TAG_NAME = "online"
SERVER_NAME = "GreatAI-Server"
SE4ML_WEBSITE = 'https://se-ml.github.io/practices/'

View file

@ -8,12 +8,13 @@ from pydantic import BaseModel
from great_ai.large_file import LargeFile, LargeFileLocal
from great_ai.utilities.logger import get_logger
import yaml
from .constants import (
DEFAULT_LARGE_FILE_CONFIG_PATHS,
DEFAULT_TRACING_DB_FILENAME,
ENV_VAR_KEY,
PRODUCTION_KEY,
SE4ML_WEBSITE,
)
from .persistence import ParallelTinyDbDriver, TracingDatabaseDriver
@ -59,6 +60,7 @@ def configure(
large_file_implementation: Type[LargeFile] = LargeFileLocal,
should_log_exception_stack: Optional[bool] = None,
prediction_cache_size: int = 512,
disable_se4ml_banner: bool=False
) -> None:
global _context
logger = get_logger("great_ai", level=log_level)
@ -94,7 +96,14 @@ def configure(
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:

View file

@ -1,5 +1,4 @@
import inspect
from asyncio.log import logger
from functools import lru_cache, partial, wraps
from typing import (
Any,
@ -41,7 +40,6 @@ from .routes import (
T = TypeVar("T")
class GreatAI(Generic[T]):
def __init__(self, func: Callable[..., Any], version: str):
func = automatically_decorate_parameters(func)
@ -72,10 +70,7 @@ class GreatAI(Generic[T]):
redoc_url=None,
)
logger.info(
f"Current configuration: {yaml.dump(get_context().to_flat_dict(), stream=None)}"
)
@staticmethod
def deploy(
func: Optional[Callable[..., T]] = None,