-
Notifications
You must be signed in to change notification settings - Fork 332
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
Updating Enrichment status #1544
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
590ad92
minor fixes
shreyaspimpalgaonkar 4c271e5
up
shreyaspimpalgaonkar 610c1db
adding bin support and make it default (#1508)
emrgnt-cmplxty 2f674dd
up (#1510)
emrgnt-cmplxty 255bf73
up
shreyaspimpalgaonkar 41e0f33
Merge remote-tracking branch 'origin/minor-fixes' into enrichment_status
shreyaspimpalgaonkar 080d8cb
cleanup (#1512)
emrgnt-cmplxty 7acb9b9
Merge branch 'dev-minor' into enrichment_status
emrgnt-cmplxty ca6761a
Merge remote-tracking branch 'origin/main' into enrichment_status
shreyaspimpalgaonkar 2b71f74
cleanup; pre-commit
shreyaspimpalgaonkar a57dbbb
rm launch json
shreyaspimpalgaonkar 34b9158
checkin work
shreyaspimpalgaonkar 232a148
Merge remote-tracking branch 'origin/main' into enrichment_status
shreyaspimpalgaonkar ce73f2e
up
shreyaspimpalgaonkar ef87b47
modify endpoint
shreyaspimpalgaonkar 24abc6d
up
shreyaspimpalgaonkar 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 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 |
---|---|---|
|
@@ -32,3 +32,5 @@ dist/ | |
*.test | ||
go.work | ||
go.work.sum | ||
|
||
.vscode/ |
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import json | ||
import logging | ||
import math | ||
import uuid | ||
|
||
from core import GenerationConfig | ||
from core import R2RException | ||
|
||
from ...services import KgService | ||
from core.base.abstractions import KGEnrichmentStatus | ||
|
||
logger = logging.getLogger() | ||
|
||
|
@@ -13,6 +16,10 @@ def simple_kg_factory(service: KgService): | |
|
||
def get_input_data_dict(input_data): | ||
for key, value in input_data.items(): | ||
|
||
if key == "collection_id": | ||
input_data[key] = uuid.UUID(value) | ||
|
||
if key == "kg_creation_settings": | ||
input_data[key] = json.loads(value) | ||
input_data[key]["generation_config"] = GenerationConfig( | ||
|
@@ -61,32 +68,50 @@ async def enrich_graph(input_data): | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a check to ensure |
||
input_data = get_input_data_dict(input_data) | ||
|
||
num_communities = await service.kg_clustering( | ||
collection_id=input_data["collection_id"], | ||
**input_data["kg_enrichment_settings"], | ||
) | ||
num_communities = num_communities[0]["num_communities"] | ||
# TODO - Do not hardcode the number of parallel communities, | ||
# make it a configurable parameter at runtime & add server-side defaults | ||
parallel_communities = min(100, num_communities) | ||
|
||
total_workflows = math.ceil(num_communities / parallel_communities) | ||
for i in range(total_workflows): | ||
input_data_copy = input_data.copy() | ||
input_data_copy["offset"] = i * parallel_communities | ||
input_data_copy["limit"] = min( | ||
parallel_communities, | ||
num_communities - i * parallel_communities, | ||
try: | ||
num_communities = await service.kg_clustering( | ||
collection_id=input_data["collection_id"], | ||
**input_data["kg_enrichment_settings"], | ||
) | ||
# running i'th workflow out of total_workflows | ||
logger.info( | ||
f"Running kg community summary for {i+1}'th workflow out of total {total_workflows} workflows" | ||
num_communities = num_communities[0]["num_communities"] | ||
# TODO - Do not hardcode the number of parallel communities, | ||
# make it a configurable parameter at runtime & add server-side defaults | ||
parallel_communities = min(100, num_communities) | ||
|
||
total_workflows = math.ceil(num_communities / parallel_communities) | ||
for i in range(total_workflows): | ||
input_data_copy = input_data.copy() | ||
input_data_copy["offset"] = i * parallel_communities | ||
input_data_copy["limit"] = min( | ||
parallel_communities, | ||
num_communities - i * parallel_communities, | ||
) | ||
# running i'th workflow out of total_workflows | ||
logger.info( | ||
f"Running kg community summary for {i+1}'th workflow out of total {total_workflows} workflows" | ||
) | ||
await kg_community_summary( | ||
input_data=input_data_copy, | ||
) | ||
|
||
await service.providers.database.set_workflow_status( | ||
id=input_data["collection_id"], | ||
status_type="kg_enrichment_status", | ||
status=KGEnrichmentStatus.SUCCESS, | ||
) | ||
await kg_community_summary( | ||
input_data=input_data_copy, | ||
return { | ||
"result": "successfully ran kg community summary workflows" | ||
} | ||
|
||
except Exception as e: | ||
|
||
await service.providers.database.set_workflow_status( | ||
id=input_data["collection_id"], | ||
status_type="kg_enrichment_status", | ||
status=KGEnrichmentStatus.FAILED, | ||
) | ||
|
||
return {"result": "successfully ran kg community summary workflows"} | ||
raise R2RException(f"Error in enriching graph: {e}") | ||
|
||
async def kg_community_summary(input_data): | ||
|
||
|
This file contains 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 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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a check to ensure
chunk_enrichment_settings
is not None before accessingchunk_enrichment_settings.enable_chunk_enrichment
to avoid potential AttributeError.