Skip to content

Commit e57e66b

Browse files
fix: update parse_obj to model_validate (#511)
1 parent d665143 commit e57e66b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

ingest_api/runtime/src/services.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import src.schemas as schemas
55
from boto3.dynamodb import conditions
66
from boto3.dynamodb.types import DYNAMODB_CONTEXT
7-
from pydantic import parse_obj_as
7+
from pydantic import TypeAdapter
88

99
if TYPE_CHECKING:
1010
from mypy_boto3_dynamodb.service_resource import Table
@@ -25,7 +25,7 @@ def fetch_one(self, username: str, ingestion_id: str):
2525
Key={"created_by": username, "id": ingestion_id},
2626
)
2727
try:
28-
return schemas.Ingestion.parse_obj(response["Item"])
28+
return schemas.Ingestion.model_validate(response["Item"])
2929
except KeyError:
3030
raise NotInDb("Record not found")
3131

@@ -38,8 +38,9 @@ def fetch_many(
3838
**{"Limit": limit} if limit else {},
3939
**{"ExclusiveStartKey": next} if next else {},
4040
)
41+
list_of_ingestions = TypeAdapter(List[schemas.Ingestion])
4142
return {
42-
"items": parse_obj_as(List[schemas.Ingestion], response["Items"]),
43+
"items": list_of_ingestions.validate_python(response["Items"]),
4344
"next": response.get("LastEvaluatedKey"),
4445
}
4546

ingest_api/runtime/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ def example_ingestion(example_stac_item):
162162
id=example_stac_item["id"],
163163
created_by="test-user",
164164
status=schemas.Status.queued,
165-
item=Item.parse_obj(example_stac_item),
165+
item=Item.model_validate(example_stac_item),
166166
created_at=datetime.now(),
167167
)

scripts/run-local-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/bin/bash
22
set -e
33

4+
# =================================================================
5+
# Ensure all Python dependencies are installed
6+
# =================================================================
7+
echo "--- Installing all development dependencies ---"
8+
pip install -r ingest_api/runtime/requirements_dev.txt
9+
echo "--- Dependency installation complete ---"
10+
# =================================================================
11+
412
# Lint
513
pre-commit run --all-files
614

0 commit comments

Comments
 (0)