From ec74eb2d6ffcaf6ec0b6634b0c0bebfac916e244 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Wed, 22 Jun 2022 15:10:36 +0200 Subject: [PATCH] Add startup message --- great_ai/src/great_ai/great_ai/constants.py | 2 ++ great_ai/src/great_ai/great_ai/context.py | 13 +++++++++++-- great_ai/src/great_ai/great_ai/deploy/great_ai.py | 7 +------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/great_ai/src/great_ai/great_ai/constants.py b/great_ai/src/great_ai/great_ai/constants.py index eaaa7ac..170d15e 100644 --- a/great_ai/src/great_ai/great_ai/constants.py +++ b/great_ai/src/great_ai/great_ai/constants.py @@ -24,3 +24,5 @@ DEVELOPMENT_TAG_NAME = "development" ONLINE_TAG_NAME = "online" SERVER_NAME = "GreatAI-Server" + +SE4ML_WEBSITE = 'https://se-ml.github.io/practices/' diff --git a/great_ai/src/great_ai/great_ai/context.py b/great_ai/src/great_ai/great_ai/context.py index 4c67505..39d0c3a 100644 --- a/great_ai/src/great_ai/great_ai/context.py +++ b/great_ai/src/great_ai/great_ai/context.py @@ -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: diff --git a/great_ai/src/great_ai/great_ai/deploy/great_ai.py b/great_ai/src/great_ai/great_ai/deploy/great_ai.py index 57a11d6..92a8181 100644 --- a/great_ai/src/great_ai/great_ai/deploy/great_ai.py +++ b/great_ai/src/great_ai/great_ai/deploy/great_ai.py @@ -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,