From 213343c0f51013ec4c018d5ae1950128b7688858 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Thu, 23 May 2024 09:52:19 +0200 Subject: [PATCH] update stac-fastapi-pgstac version and rename env files --- .../data/noaa-emergency-response.json | 2 +- .gitignore | 2 +- infrastructure/config.py | 2 +- runtimes/eoapi/raster/eoapi/raster/config.py | 2 +- runtimes/eoapi/stac/eoapi/stac/app.py | 22 +++++++------------ runtimes/eoapi/stac/eoapi/stac/config.py | 2 +- runtimes/eoapi/stac/pyproject.toml | 2 +- runtimes/eoapi/vector/eoapi/vector/config.py | 2 +- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.github/workflows/data/noaa-emergency-response.json b/.github/workflows/data/noaa-emergency-response.json index 41ed177..b0b6e5b 100644 --- a/.github/workflows/data/noaa-emergency-response.json +++ b/.github/workflows/data/noaa-emergency-response.json @@ -1 +1 @@ -{"id":"noaa-emergency-response", "title": "NOAA Emergency Response Imagery", "description":"NOAA Emergency Response Imagery hosted on AWS Public Dataset.","stac_version":"1.0.0","license":"public-domain","links":[],"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2005-01-01T00:00:00Z",null]]}}} +{"type": "Collection", "id":"noaa-emergency-response", "title": "NOAA Emergency Response Imagery", "description":"NOAA Emergency Response Imagery hosted on AWS Public Dataset.","stac_version":"1.0.0","license":"public-domain","links":[],"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2005-01-01T00:00:00Z",null]]}}} diff --git a/.gitignore b/.gitignore index 1ec4f06..556c695 100644 --- a/.gitignore +++ b/.gitignore @@ -168,4 +168,4 @@ node_modules/ .pgdata .ruff_cache/ -.env-local +.env-cdk diff --git a/infrastructure/config.py b/infrastructure/config.py index b745254..1342991 100644 --- a/infrastructure/config.py +++ b/infrastructure/config.py @@ -118,7 +118,7 @@ class AppConfig(BaseSettings): ) model_config = SettingsConfigDict( - env_file=".env", yaml_file="config.yaml", extra="allow" + env_file=".env-cdk", yaml_file="config.yaml", extra="allow" ) @field_validator("tags") diff --git a/runtimes/eoapi/raster/eoapi/raster/config.py b/runtimes/eoapi/raster/eoapi/raster/config.py index 12f7cf9..53789e6 100644 --- a/runtimes/eoapi/raster/eoapi/raster/config.py +++ b/runtimes/eoapi/raster/eoapi/raster/config.py @@ -16,7 +16,7 @@ class ApiSettings(BaseSettings): model_config = { "env_prefix": "EOAPI_RASTER_", - "env_file": ".env-local", + "env_file": ".env", "extra": "allow", } diff --git a/runtimes/eoapi/stac/eoapi/stac/app.py b/runtimes/eoapi/stac/eoapi/stac/app.py index dd43914..af1e159 100644 --- a/runtimes/eoapi/stac/eoapi/stac/app.py +++ b/runtimes/eoapi/stac/eoapi/stac/app.py @@ -40,7 +40,7 @@ templates = Jinja2Templates(directory=str(resources_files(__package__) / "templates")) # type: ignore api_settings = ApiSettings() -settings = Settings() +settings = Settings(enable_response_models=True) extensions_map = { "transaction": TransactionExtension( @@ -92,7 +92,13 @@ async def lifespan(app: FastAPI): ) api = StacApi( - app=FastAPI(title=api_settings.name, lifespan=lifespan), + app=FastAPI( + title=api_settings.name, + lifespan=lifespan, + openapi_url="/api", + docs_url="/api.html", + redoc_url=None, + ), title=api_settings.name, description=api_settings.name, settings=settings, @@ -106,18 +112,6 @@ async def lifespan(app: FastAPI): app = api.app -@app.on_event("startup") -async def startup_event(): - """Connect to database on startup.""" - await connect_to_db(app) - - -@app.on_event("shutdown") -async def shutdown_event(): - """Close database connection.""" - await close_db_connection(app) - - if api_settings.titiler_endpoint: # Register to the TiTiler extension to the api extension = TiTilerExtension() diff --git a/runtimes/eoapi/stac/eoapi/stac/config.py b/runtimes/eoapi/stac/eoapi/stac/config.py index 2cbd270..8c29ad9 100644 --- a/runtimes/eoapi/stac/eoapi/stac/config.py +++ b/runtimes/eoapi/stac/eoapi/stac/config.py @@ -37,6 +37,6 @@ def parse_cors_methods(cls, v): model_config = { "env_prefix": "EOAPI_STAC_", - "env_file": ".env-local", + "env_file": ".env", "extra": "allow", } diff --git a/runtimes/eoapi/stac/pyproject.toml b/runtimes/eoapi/stac/pyproject.toml index fbaea5a..30b0e02 100644 --- a/runtimes/eoapi/stac/pyproject.toml +++ b/runtimes/eoapi/stac/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "stac-fastapi.pgstac==3.0.0a0", + "stac-fastapi.pgstac==3.0.0a1", "jinja2>=2.11.2,<4.0.0", "starlette-cramjam>=0.3,<0.4", "importlib_resources>=1.1.0;python_version<'3.9'", diff --git a/runtimes/eoapi/vector/eoapi/vector/config.py b/runtimes/eoapi/vector/eoapi/vector/config.py index c039307..1b5d1fa 100644 --- a/runtimes/eoapi/vector/eoapi/vector/config.py +++ b/runtimes/eoapi/vector/eoapi/vector/config.py @@ -18,7 +18,7 @@ class ApiSettings(BaseSettings): model_config = { "env_prefix": "EOAPI_VECTOR_", - "env_file": ".env-local", + "env_file": ".env", "extra": "allow", }