Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
run: >
sed -i
-e 's/AWS_ACCOUNT_ID_PLACEHOLDER/${{ secrets.AWS_ACCOUNT_ID }}/g'
-e 's/AWS_DATABASE_URL_SECRET_NAME_PLACEHOLDER/${{ vars.AWS_DATABASE_URL_SECRET_NAME }}/g'
-e 's/AWS_EXECUTION_ROLE_PLACEHOLDER/${{ vars.AWS_EXECUTION_ROLE }}/g'
-e 's/AWS_REGION_PLACEHOLDER/${{ vars.AWS_REGION }}/g'
task-definition.json
Expand Down
30 changes: 0 additions & 30 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
from pathlib import Path
from typing import Annotated

from pydantic import (
AliasChoices,
Field,
PostgresDsn,
TypeAdapter,
field_validator,
)
from pydantic_settings import BaseSettings, SettingsConfigDict

from .util import normalize_postgres_dsn_for_atoti_jdbc


class Config(BaseSettings):
"""Hold all the configuration properties of the app, not only the ones related to Atoti.
Expand All @@ -31,21 +19,3 @@ class Config(BaseSettings):

# The $PORT environment variable is used by most PaaS to indicate the port the app server should bind to.
port: int = 9090

user_content_storage: Annotated[
PostgresDsn | Path | None,
Field(
# $DATABASE_URL is used by some PaaS such to designate the URL of the app's primary database.
# For instance: https://devcenter.heroku.com/articles/heroku-postgresql#designating-a-primary-database.
validation_alias=AliasChoices("user_content_storage", "database_url")
),
] = Path("content")

@field_validator("user_content_storage")
@classmethod
def normalize_postgres_dsn(cls, value: object) -> object:
try:
postgres_dsn: PostgresDsn = TypeAdapter(PostgresDsn).validate_python(value)
return normalize_postgres_dsn_for_atoti_jdbc(postgres_dsn)
except ValueError:
return value
24 changes: 4 additions & 20 deletions app/start_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from asyncio import to_thread
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from pathlib import Path

import atoti as tt
import httpx
from atoti_jdbc import UserContentStorageConfig

from .config import Config
from .create_and_join_tables import create_and_join_tables
Expand All @@ -15,23 +13,6 @@
from .opentelemetry import span


def _get_session_config(config: Config, /) -> tt.SessionConfig:
user_content_storage: Path | UserContentStorageConfig | None = None

if config.user_content_storage is not None:
user_content_storage = (
config.user_content_storage
if isinstance(config.user_content_storage, Path)
else UserContentStorageConfig(url=str(config.user_content_storage))
)

return tt.SessionConfig(
logging=tt.LoggingConfig(destination=sys.stdout),
port=config.port,
user_content_storage=user_content_storage,
)


@span
def _create_data_model(session: tt.Session, /) -> None:
create_and_join_tables(session)
Expand All @@ -45,7 +26,10 @@ async def start_session(
http_client: httpx.AsyncClient,
) -> AsyncGenerator[tt.Session]:
"""Start the session, declare the data model and load the initial data."""
session_config = _get_session_config(config)
session_config = tt.SessionConfig(
logging=tt.LoggingConfig(destination=sys.stdout),
port=config.port,
)
session = await to_thread(tt.Session.start, session_config)
try:
with tt.mapping_lookup(check=config.check_mapping_lookups):
Expand Down
3 changes: 0 additions & 3 deletions app/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from .column import column as column
from .fact_based_hierarchy import fact_based_hierarchy as fact_based_hierarchy
from .normalize_postgres_dsn_for_atoti_jdbc import (
normalize_postgres_dsn_for_atoti_jdbc as normalize_postgres_dsn_for_atoti_jdbc,
)
from .read_json import read_json as read_json
from .reverse_geocode import reverse_geocode as reverse_geocode
from .run_periodically import run_periodically as run_periodically
27 changes: 0 additions & 27 deletions app/util/normalize_postgres_dsn_for_atoti_jdbc.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ version = "0.1.0"
# - Dockerfile`'s `FROM` commands.
requires-python = ">=3.12"
dependencies = [
"atoti[jdbc,observability]",
"atoti[observability]",
"httpx",
"opentelemetry-exporter-otlp-proto-http",
"opentelemetry-instrumentation-httpx",
Expand Down
8 changes: 1 addition & 7 deletions task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@
"import httpx; httpx.get('http://localhost/actuator/health/readiness').raise_for_status()"
],
"startPeriod": 30
},
"secrets": [
{
"name": "DATABASE_URL",
"valueFrom": "arn:aws:secretsmanager:AWS_REGION_PLACEHOLDER:AWS_ACCOUNT_ID_PLACEHOLDER:secret:atoti-project-template/AWS_DATABASE_URL_SECRET_NAME_PLACEHOLDER"
}
]
}
}
],
"family": "atoti-project-template",
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def project_name_fixture() -> str:
def config_fixture() -> Config:
return Config(
port=0,
user_content_storage=None,
)


Expand Down
31 changes: 0 additions & 31 deletions tests/test_normalize_dsn_for_atoti_jdbc.py

This file was deleted.

33 changes: 2 additions & 31 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.