diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7adca86..388d910 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/app/config.py b/app/config.py index dca3b68..de41b25 100644 --- a/app/config.py +++ b/app/config.py @@ -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. @@ -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 diff --git a/app/start_session.py b/app/start_session.py index 64c6dfc..ce710e1 100644 --- a/app/start_session.py +++ b/app/start_session.py @@ -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 @@ -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) @@ -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): diff --git a/app/util/__init__.py b/app/util/__init__.py index fc5da4b..80ff382 100644 --- a/app/util/__init__.py +++ b/app/util/__init__.py @@ -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 diff --git a/app/util/normalize_postgres_dsn_for_atoti_jdbc.py b/app/util/normalize_postgres_dsn_for_atoti_jdbc.py deleted file mode 100644 index 8f2f368..0000000 --- a/app/util/normalize_postgres_dsn_for_atoti_jdbc.py +++ /dev/null @@ -1,27 +0,0 @@ -from urllib.parse import urlencode, urlparse - -from pydantic import PostgresDsn, TypeAdapter - - -def normalize_postgres_dsn_for_atoti_jdbc(url: PostgresDsn, /) -> PostgresDsn: - parts = urlparse(str(url)) - - parts = parts._replace(scheme="postgresql") - - query_parts: list[str] = [] - - if parts.query: - query_parts.append(parts.query) - - if parts.username or parts.password: - query_parts.append( - urlencode({"user": parts.username, "password": parts.password}) - ) - # Remove username and password. - parts = parts._replace(netloc=parts.netloc.split("@", maxsplit=1).pop()) - - if query_parts: - parts = parts._replace(query="&".join(query_parts)) - - new_url = parts.geturl() - return TypeAdapter(PostgresDsn).validate_python(new_url) diff --git a/pyproject.toml b/pyproject.toml index 7eb9210..e1fff63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/task-definition.json b/task-definition.json index 59b62be..dedaea1 100644 --- a/task-definition.json +++ b/task-definition.json @@ -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", diff --git a/tests/conftest.py b/tests/conftest.py index 9ccaca6..b7e0e45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,7 +19,6 @@ def project_name_fixture() -> str: def config_fixture() -> Config: return Config( port=0, - user_content_storage=None, ) diff --git a/tests/test_normalize_dsn_for_atoti_jdbc.py b/tests/test_normalize_dsn_for_atoti_jdbc.py deleted file mode 100644 index 92daa12..0000000 --- a/tests/test_normalize_dsn_for_atoti_jdbc.py +++ /dev/null @@ -1,31 +0,0 @@ -import pytest -from pydantic import PostgresDsn, TypeAdapter - -from app.util import normalize_postgres_dsn_for_atoti_jdbc - - -@pytest.mark.parametrize( - ("value", "expected_output"), - [ - ( - "postgres://foo:bar@example.com", - "postgresql://example.com?user=foo&password=bar", - ), - ( - "postgres://foo:bar@example.com/db", - "postgresql://example.com/db?user=foo&password=bar", - ), - ( - "postgres://foo:bar@example.com:5432/db?test=baz", - "postgresql://example.com:5432/db?test=baz&user=foo&password=bar", - ), - ( - "postgres://foo:bar@example.com:5432/db?test1=baz&test2=foo#search", - "postgresql://example.com:5432/db?test1=baz&test2=foo&user=foo&password=bar#search", - ), - ], -) -def test_normalize_dsn_for_atoti_jdbc(value: str, expected_output: str) -> None: - validated_value: PostgresDsn = TypeAdapter(PostgresDsn).validate_python(value) - output = str(normalize_postgres_dsn_for_atoti_jdbc(validated_value)) - assert output == expected_output diff --git a/uv.lock b/uv.lock index 6cdc1ea..b10bf1b 100644 --- a/uv.lock +++ b/uv.lock @@ -29,7 +29,7 @@ name = "app" version = "0.1.0" source = { virtual = "." } dependencies = [ - { name = "atoti", extra = ["jdbc", "observability"] }, + { name = "atoti", extra = ["observability"] }, { name = "httpx" }, { name = "opentelemetry-exporter-otlp-proto-http" }, { name = "opentelemetry-instrumentation-httpx" }, @@ -52,7 +52,7 @@ dev = [ [package.metadata] requires-dist = [ - { name = "atoti", extras = ["jdbc", "observability"] }, + { name = "atoti", extras = ["observability"] }, { name = "httpx" }, { name = "opentelemetry-exporter-otlp-proto-http" }, { name = "opentelemetry-instrumentation-httpx" }, @@ -89,10 +89,6 @@ wheels = [ ] [package.optional-dependencies] -jdbc = [ - { name = "atoti-client-jdbc" }, - { name = "atoti-server-jdbc" }, -] observability = [ { name = "atoti-client-observability" }, { name = "atoti-server-observability" }, @@ -118,19 +114,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/1f/18/203bb444c0abfc23b62ccf88f96cdd6967ddf030431aed4c176912d44e78/atoti_client-0.9.14-py3-none-any.whl", hash = "sha256:c6b202049d3eb03ef28656a9811fa8202aa0a6ff6a1e44f5f4d8d67bbcb2773b", size = 4590426, upload-time = "2026-04-17T21:27:36.221Z" }, ] -[[package]] -name = "atoti-client-jdbc" -version = "0.9.14" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "atoti-client" }, - { name = "pydantic" }, - { name = "typing-extensions" }, -] -wheels = [ - { url = "https://files.pythonhosted.org/packages/af/c3/a81cc94029fe230b9598f6d6b8e85761e2c5b1e816d3ce390e6177e0e8b3/atoti_client_jdbc-0.9.14-py3-none-any.whl", hash = "sha256:1d5feceb1fc0d3c134458f03ba7fb8fa1c4539f3fa6dbd2adf5cf3dfdb321532", size = 7844, upload-time = "2026-04-17T21:27:50.295Z" }, -] - [[package]] name = "atoti-client-observability" version = "0.9.14" @@ -176,18 +159,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8a/ea/d671f5fb004a725f41dc97f8cb3eb27afa083099a1ee3305e77bf55a9c7d/atoti_server-0.9.14-py3-none-any.whl", hash = "sha256:353a0406ddff88368125a791e567df9b6fdd5ed2308a785c0db0f328dd09d0e9", size = 128454770, upload-time = "2026-04-17T21:28:01.569Z" }, ] -[[package]] -name = "atoti-server-jdbc" -version = "0.9.14" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "atoti-core" }, - { name = "typing-extensions" }, -] -wheels = [ - { url = "https://files.pythonhosted.org/packages/dd/17/a934e3cef89d4453152eb43e818a83586905124a6179d3e5ba83bd0d13ac/atoti_server_jdbc-0.9.14-py3-none-any.whl", hash = "sha256:ce326f1b0900f851a06750fbc08b2d806bd87e378fd45249b4f0d19bb453be78", size = 18464566, upload-time = "2026-04-17T21:28:33.186Z" }, -] - [[package]] name = "atoti-server-observability" version = "0.9.14"