Skip to content
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

Validation Check for the validated extracts for secondary summary #2298

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions per/ops_learning_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def add_used_ops_learnings_sector(
if not sector_instance:
logger.info(f"Sector '{sector}' not found.")
return
ops_learning_instances = OpsLearning.objects.filter(id__in=used_ops_learnings)
ops_learning_instances = OpsLearning.objects.filter(is_validated=True, id__in=used_ops_learnings)
if len(ops_learning_instances):
ops_learning_sector, created = (
OpsLearningSectorCacheResponse.objects.select_related("filter_response", "sector")
Expand Down Expand Up @@ -205,7 +205,7 @@ def add_used_ops_learnings_component(
if not component_instance:
logger.info(f"Component '{component}' not found.")
return
ops_learning_instances = OpsLearning.objects.filter(id__in=used_ops_learnings)
ops_learning_instances = OpsLearning.objects.filter(is_validated=True, id__in=used_ops_learnings)
if len(ops_learning_instances):
ops_learning_component, created = (
OpsLearningComponentCacheResponse.objects.select_related("filter_response", "component")
Expand Down Expand Up @@ -276,7 +276,7 @@ def fetch_ops_learnings(cls, filter_data):
"excerpts_id",
"component_title",
"sector_title",
"learning",
"learning_validated",
"country_id",
"country_name",
"region_id",
Expand All @@ -287,10 +287,7 @@ def fetch_ops_learnings(cls, filter_data):
)
)
ops_learning_df = ops_learning_df.rename(
columns={
"component_title": "component",
"sector_title": "sector",
}
columns={"component_title": "component", "sector_title": "sector", "learning_validated": "learning"}
)
ops_learning_df.set_index("id", inplace=True)
return ops_learning_df
Expand Down Expand Up @@ -795,14 +792,14 @@ def _modify_format(summary) -> str:

# Attempt to parse the summary as a dictionary
if _validate_text_is_dictionary(summary):
formated_summary = ast.literal_eval(summary)
formatted_summary = ast.literal_eval(summary)
else:
formatted_summary = _modify_format(summary)
formatted_summary = ast.literal_eval(formatted_summary)

# Checking if the generated summary is empty
if bool(formated_summary):
return formated_summary
if bool(formatted_summary):
return formatted_summary

# NOTE: Generating the summary if summary is empty
while retires < MAX_RETRIES:
Expand Down