in service/app/main.py [0:0]
def save_metadata_to_dynamo(bag, s3_prefix, local_file_name, s3_bucket):
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(os.environ["dynamo_table_name"])
df = bag.topic_table.to_dict("records")
logging.info(df)
item = {
"bag_file_prefix": s3_prefix,
"bag_file": local_file_name,
"bag_file_bucket": s3_bucket,
}
for t in df:
item[t["Topics"]] = {str(k): str(v) for k, v in t.items() if k != "Topics"}
table.put_item(Item=item)