Skip to content

Commit

Permalink
fix cosmos test
Browse files Browse the repository at this point in the history
  • Loading branch information
dayesouza committed Feb 10, 2025
1 parent 7539e0b commit 6496350
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions graphrag/storage/cosmosdb_pipeline_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import re
from collections.abc import Iterator
from datetime import datetime, timezone
from io import BytesIO, StringIO
from typing import Any

Expand Down Expand Up @@ -330,8 +331,12 @@ def _get_prefix(self, key: str) -> str:
async def get_creation_date(self, key: str) -> str:
"""Get a value from the cache."""
try:
item = await self.get(key)
return get_timestamp_formatted_with_local_tz(item["_ts"])
if not self._database_client or not self._container_client:
return ""
item = self._container_client.read_item(item=key, partition_key=key)
return get_timestamp_formatted_with_local_tz(
datetime.fromtimestamp(item["_ts"], tz=timezone.utc)
)

except Exception:
log.exception("Error getting key %s", key)
Expand Down

0 comments on commit 6496350

Please sign in to comment.