Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
AlonsoGuevara committed Nov 14, 2024
1 parent 6d2427e commit d206e67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions graphrag/index/emit/table_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class TableEmitter(Protocol):
"""TableEmitter protocol for emitting tables to a destination."""

extension: str

async def emit(self, name: str, data: pd.DataFrame) -> None:
Expand Down
10 changes: 7 additions & 3 deletions graphrag/utils/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ async def _load_table_from_storage(name: str, storage: PipelineStorage) -> pd.Da
case "parquet":
return pd.read_parquet(BytesIO(await storage.get(name, as_bytes=True)))
case "json":
return pd.read_json(BytesIO(await storage.get(name, as_bytes=True)), lines=True, orient="records")
return pd.read_json(
BytesIO(await storage.get(name, as_bytes=True)),
lines=True,
orient="records",
)
case "csv":
return pd.read_csv(BytesIO(await storage.get(name, as_bytes=True)))
case _:
raise ValueError(f"Unknown file extension for {name}")
case _:
raise ValueError(f"Unknown file extension for {name}")
except Exception:
log.exception("error loading table from storage: %s", name)
raise

0 comments on commit d206e67

Please sign in to comment.