-
Notifications
You must be signed in to change notification settings - Fork 3k
Incremental indexing/file delta #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlonsoGuevara
merged 8 commits into
incremental_indexing/main
from
incremental_indexing/file_delta
Sep 11, 2024
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4680450
Merge branch 'main' into incremental_indexing/file_delta
AlonsoGuevara 057f3fe
Calculate new inputs and deleted inputs on update
AlonsoGuevara 91418d5
Semver
AlonsoGuevara 7e69faa
Merge branch 'incremental_indexing/main' into incremental_indexing/fi…
AlonsoGuevara 039d9a5
Clear ruff checks
AlonsoGuevara 3e7f732
Fix pyright
AlonsoGuevara d7474f9
Fix PyRight
AlonsoGuevara 35a5007
Ruff again
AlonsoGuevara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "patch", | ||
"description": "Calculate new inputs and deleted inputs on update" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
"""Incremental Indexing main module definition.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
"""File management and utils for Incremental Indexing.""" | ||
|
||
from typing import NamedTuple | ||
|
||
import pandas as pd | ||
|
||
from graphrag.index.storage.typing import PipelineStorage | ||
from graphrag.utils.storage import _load_table_from_storage | ||
|
||
|
||
# Output delta named tuple | ||
class InputDelta(NamedTuple): | ||
"""Named tuple for output delta.""" | ||
|
||
new_inputs: pd.DataFrame | ||
deleted_inputs: pd.DataFrame | ||
|
||
|
||
async def get_delta_docs( | ||
input_dataset: pd.DataFrame, storage: PipelineStorage | ||
) -> InputDelta: | ||
"""Get the delta between the input dataset and the final documents. | ||
|
||
Parameters | ||
---------- | ||
input_dataset : pd.DataFrame | ||
The input dataset. | ||
storage : PipelineStorage | ||
The Pipeline storage. | ||
|
||
Returns | ||
------- | ||
InputDelta | ||
The input delta. With new inputs and deleted inputs. | ||
""" | ||
final_docs = await _load_table_from_storage( | ||
"create_final_documents.parquet", storage | ||
) | ||
|
||
# Select distinct title from final docs and from dataset | ||
previous_docs = final_docs["title"].unique() | ||
dataset_docs = input_dataset["title"].unique() | ||
|
||
# Get the new documents | ||
new_docs = input_dataset[~input_dataset["title"].isin(previous_docs)] | ||
deleted_docs = final_docs[~final_docs["title"].isin(dataset_docs)] | ||
return InputDelta(new_docs, deleted_docs) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.