Skip to content

Commit 6d6a3d4

Browse files
authored
fix(deps): upgrade python packages in uv.lock files (#222)
* fix(deps): upgrade python packages in uv.lock files * fix: update PostgresSettings attributes * fix(deps): pin to mangum==0.19.0
1 parent 9407d48 commit 6d6a3d4

File tree

12 files changed

+2000
-1879
lines changed

12 files changed

+2000
-1879
lines changed

lib/stac-api/runtime/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "stac-api runtime"
55
authors = [{ name = "hrodmn", email = "henry@developmentseed.org" }]
66
requires-python = ">=3.12"
77
dependencies = [
8+
"mangum==0.19",
89
"stac-fastapi-pgstac[awslambda]>=6.0,<6.1",
910
"starlette-cramjam>=0.4,<0.5",
1011
]

lib/stac-api/runtime/src/stac_api/handler.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import asyncio
6+
import logging
67
import os
78

89
from mangum import Mangum
@@ -12,14 +13,21 @@
1213
from stac_fastapi.pgstac.db import close_db_connection, connect_to_db
1314
from utils import get_secret_dict
1415

16+
logging.basicConfig(
17+
level=logging.INFO,
18+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
19+
)
20+
logger = logging.getLogger(__name__)
21+
22+
23+
logger.info("fetching pgstac secret")
1524
secret = get_secret_dict(secret_arn_env_var="PGSTAC_SECRET_ARN")
1625
postgres_settings = PostgresSettings(
17-
postgres_host_reader=secret["host"],
18-
postgres_host_writer=secret["host"],
19-
postgres_dbname=secret["dbname"],
20-
postgres_user=secret["username"],
21-
postgres_pass=secret["password"],
22-
postgres_port=int(secret["port"]),
26+
pghost=secret["host"],
27+
pgdatabase=secret["dbname"],
28+
pguser=secret["username"],
29+
pgpassword=secret["password"],
30+
pgport=int(secret["port"]),
2331
)
2432

2533
_connection_initialized = False
@@ -38,14 +46,14 @@ def on_snapshot():
3846
app.state.readpool.close()
3947
app.state.readpool = None
4048
except Exception as e:
41-
print(f"SnapStart: Error closing database readpool: {e}")
49+
logger.info(f"SnapStart: Error closing database readpool: {e}")
4250

4351
if hasattr(app, "state") and hasattr(app.state, "writepool") and app.state.writepool:
4452
try:
4553
app.state.writepool.close()
4654
app.state.writepool = None
4755
except Exception as e:
48-
print(f"SnapStart: Error closing database writepool: {e}")
56+
logger.info(f"SnapStart: Error closing database writepool: {e}")
4957

5058
return {"statusCode": 200}
5159

@@ -71,14 +79,14 @@ def on_snap_restore():
7179
try:
7280
app.state.readpool.close()
7381
except Exception as e:
74-
print(f"SnapStart: Error closing stale readpool: {e}")
82+
logger.info(f"SnapStart: Error closing stale readpool: {e}")
7583
app.state.readpool = None
7684

7785
if hasattr(app.state, "writepool") and app.state.writepool:
7886
try:
7987
app.state.writepool.close()
8088
except Exception as e:
81-
print(f"SnapStart: Error closing stale writepool: {e}")
89+
logger.info(f"SnapStart: Error closing stale writepool: {e}")
8290
app.state.writepool = None
8391

8492
# Create fresh connection pool
@@ -93,7 +101,7 @@ def on_snap_restore():
93101
_connection_initialized = True
94102

95103
except Exception as e:
96-
print(f"SnapStart: Failed to initialize database connection: {e}")
104+
logger.error(f"SnapStart: Failed to initialize database connection: {e}")
97105
raise
98106

99107
return {"statusCode": 200}
@@ -102,13 +110,13 @@ def on_snap_restore():
102110
@app.on_event("startup")
103111
async def startup_event():
104112
"""Connect to database on startup."""
105-
print("Setting up DB connection...")
113+
logger.info("Setting up DB connection...")
106114
await connect_to_db(
107115
app,
108116
postgres_settings=postgres_settings,
109117
add_write_connection_pool=with_transactions,
110118
)
111-
print("DB connection setup.")
119+
logger.info("DB connection setup.")
112120

113121

114122
@app.on_event("shutdown")
@@ -131,5 +139,14 @@ async def shutdown_event():
131139

132140

133141
if "AWS_EXECUTION_ENV" in os.environ:
134-
loop = asyncio.get_event_loop()
135-
loop.run_until_complete(app.router.startup())
142+
logger.info("Cold start: initializing database connection...")
143+
loop = asyncio.new_event_loop()
144+
asyncio.set_event_loop(loop)
145+
loop.run_until_complete(
146+
connect_to_db(
147+
app,
148+
postgres_settings=postgres_settings,
149+
add_write_connection_pool=with_transactions,
150+
)
151+
)
152+
logger.info("Database connection initialized.")

lib/stac-api/runtime/uv.lock

Lines changed: 311 additions & 321 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/stac-auth-proxy/runtime/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
description = "stac-auth-proxy-api runtime"
55
requires-python = ">=3.12"
66
dependencies = [
7-
"mangum>=0.19.0",
7+
"mangum==0.19",
88
"stac-auth-proxy>=0.6,<1",
99
]
1010

lib/stac-auth-proxy/runtime/uv.lock

Lines changed: 167 additions & 195 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/stac-loader/runtime/uv.lock

Lines changed: 249 additions & 239 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/stactools-item-generator/runtime/uv.lock

Lines changed: 69 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tipg-api/runtime/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
description = "tipg-api runtime"
55
requires-python = ">=3.12"
66
dependencies = [
7-
"mangum>=0.19.0",
7+
"mangum==0.19",
88
"tipg>=1.2,<1.3",
99
]
1010

lib/tipg-api/runtime/uv.lock

Lines changed: 257 additions & 237 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/titiler-pgstac-api/runtime/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "titiler-pgstac-api runtime"
55
requires-python = ">=3.12"
66
dependencies = [
77
"titiler-pgstac[psycopg-binary]>=1.9.0,<1.10",
8-
"mangum>=0.19.0",
8+
"mangum==0.19",
99
]
1010

1111
[dependency-groups]

0 commit comments

Comments
 (0)