Skip to content

Commit dc830f1

Browse files
author
Bob Strahan
committed
shorten cache PK.. write cache only on outer exception handler
1 parent 333e20b commit dc830f1

File tree

1 file changed

+2
-13
lines changed
  • lib/idp_common_pkg/idp_common/classification

1 file changed

+2
-13
lines changed

lib/idp_common_pkg/idp_common/classification/service.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ def _get_cache_key(self, document: Document) -> str:
10031003
Returns:
10041004
Cache key string
10051005
"""
1006-
return f"classcache#{document.id}#{document.workflow_execution_arn}"
1006+
workflow_id = document.workflow_execution_arn.split(":")[-1]
1007+
return f"classcache#{document.id}#{workflow_id}"
10071008

10081009
def _get_cached_page_classifications(
10091010
self, document: Document
@@ -1247,18 +1248,6 @@ def classify_document(self, document: Document) -> Document:
12471248
if page_id in document.pages:
12481249
document.pages[page_id].classification = "unclassified"
12491250
document.pages[page_id].confidence = 0.0
1250-
1251-
# Cache successful page classifications before raising exception
1252-
successful_results = [
1253-
r
1254-
for r in all_page_results
1255-
if "error" not in r.classification.metadata
1256-
]
1257-
if successful_results:
1258-
self._cache_successful_page_classifications(
1259-
document, successful_results
1260-
)
1261-
12621251
# raise exception to enable client retries
12631252
raise
12641253
else:

0 commit comments

Comments
 (0)