Skip to content

Commit

Permalink
Update auto_entry_extraction_status to FAILED
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Dec 21, 2023
1 parent ece1344 commit 04fda4e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/deepl_integration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def auto_trigger_request_to_extractor(cls, lead):
payload = {
"documents": [
{
"client_id": cls.get_client_id(lead), # static clientid for mock
"client_id": cls.get_client_id(lead),
"text_extraction_id": str(lead_preview.text_extraction_id)
}
],
Expand All @@ -378,6 +378,8 @@ def auto_trigger_request_to_extractor(cls, lead):

except Exception:
logger.error('Entry Extraction send failed, Exception occurred!!', exc_info=True)
lead.auto_entry_extraction_status = Lead.AutoExtractionStatus.FAILED
lead.save(update_fields=('auto_entry_extraction_status',))
_response = locals().get('response')
logger.error(
'Entry Extraction send failed!!',
Expand All @@ -387,6 +389,7 @@ def auto_trigger_request_to_extractor(cls, lead):
},
)

# --- Callback logics
@staticmethod
def _get_or_create_models_version(models_data):
def get_versions_map():
Expand Down Expand Up @@ -442,7 +445,8 @@ def get_tags_map():
current_tags_map = get_tags_map()
# Check if new tags needs to be created
new_tags = [
tag for tag in tags
tag
for tag in tags
if tag not in current_tags_map
]
if new_tags:
Expand All @@ -467,16 +471,13 @@ def _process_model_preds(cls, model_version, current_tags_map, draft_entry, mode

tags = model_prediction.get('classification', {}) # NLP TagId
values = model_prediction.get('values', []) # Raw value

common_attrs = dict(
model_version=model_version,
draft_entry_id=draft_entry.id,
)
new_predictions = []
for category_tag, tags in tags.items():
common_attrs = dict(
model_version=model_version,
draft_entry_id=draft_entry.id
)
for tag, prediction_data in tags.items():
prediction_value = prediction_data.get('prediction')
threshold_value = prediction_data.get('threshold')
Expand Down Expand Up @@ -540,8 +541,8 @@ def save_data(cls, lead, data_url):
(data['classification_model_info']['name'], data['classification_model_info']['version'])
]
cls._process_model_preds(model_version, current_tags_map, draft, model_preds)
lead.auto_entry_extraction_status = Lead.AutoExtractionStatus.SUCCESS
lead.save(update_fields=('auto_entry_extraction_status',))
lead.auto_entry_extraction_status = Lead.AutoExtractionStatus.SUCCESS
lead.save(update_fields=('auto_entry_extraction_status',))
return lead


Expand Down

0 comments on commit 04fda4e

Please sign in to comment.