Skip to content

Commit

Permalink
Log project version
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Oct 10, 2024
1 parent 7b69f7b commit 81e5642
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import cast

from src.common.setup_logging import ExtendedLogger, setup_logging, setup_sentry
from src.common.utils import get_project_version

setup_logging()
setup_sentry()
Expand All @@ -16,6 +17,9 @@ async def app() -> None:
from src.startup_checks import startup_checks
from src.validators.tasks import create_tasks

version = get_project_version()
logger.info('Starting DVT Sidecar service %s', version)

is_checks_ok = await startup_checks()
if not is_checks_ok:
return
Expand Down
16 changes: 16 additions & 0 deletions src/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import asyncio
import functools
from pathlib import Path
from typing import Iterator, overload

import tomli


@overload
def to_chunks(items: list, size: int) -> Iterator[list]:
Expand Down Expand Up @@ -28,3 +32,15 @@ def format_error(e: Exception) -> str:
return repr(e)

return str(e)


@functools.cache
def get_project_meta() -> dict:
toml_path = Path() / 'pyproject.toml'

with toml_path.open(mode='rb') as pyproject:
return tomli.load(pyproject)


def get_project_version() -> str:
return get_project_meta()['tool']['poetry']['version']

0 comments on commit 81e5642

Please sign in to comment.