Skip to content

Commit

Permalink
fix location serializing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Jan 2, 2024
1 parent 7f102a5 commit 5106be0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gene/database/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import click
from boto3.dynamodb.conditions import Key
from botocore.exceptions import ClientError
from pydantic import BaseModel

from gene.database.database import (
AWS_ENV_VAR_NAME,
Expand Down Expand Up @@ -382,6 +383,12 @@ def add_record(self, record: Dict, src_name: SourceName) -> None:
label_and_type = f"{concept_id.lower()}##identity"
record["label_and_type"] = label_and_type
record["item_type"] = "identity"
for i, location in enumerate(record.get("locations", [])):
if isinstance(location, BaseModel):
record["locations"][i] = location.model_dump(
mode="json", exclude_none=True
)

try:
self.batch.put_item(Item=record)
except ClientError as e:
Expand Down

0 comments on commit 5106be0

Please sign in to comment.