Repository navigation
[Python] Honor exception_level on NotFound in VertexAIFeatureStore enrichment handlers - #41705
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR cleanly resolves two bugs in the Vertex AI Feature Store enrichment handlers: it prevents an UnboundLocalError when fetch_feature_values raises NotFound under ExceptionLevel.QUIET in VertexAIFeatureStoreEnrichmentHandler, and updates VertexAIFeatureStoreLegacyEnrichmentHandler to properly respect exception_level (RAISE, WARN, and QUIET) on NotFound exceptions. Comprehensive unit tests are included for all ExceptionLevel variants across both handlers.
🔍 General Feedback
- The control flow in
except NotFound:is clean, concise, and consistent across both the online store and legacy handlers. - Retaining the existing
__init__existence validation preserves backward compatibility with existing unit tests (TestVertexAIFeatureStoreHandlerInit). - Test coverage in
vertex_ai_feature_store_test.pythoroughly exercisesQUIET,WARN, andRAISEmodes for both handlers.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @tvalentyn for label python. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Addresses #41345
Summary
UnboundLocalErrorinVertexAIFeatureStoreEnrichmentHandler.__call__whenfetch_feature_valuesraisesNotFoundandexception_level=ExceptionLevel.QUIETby returning(request, beam.Row())without logging.exception_level(RAISE,WARN,QUIET) onNotFoundinVertexAIFeatureStoreLegacyEnrichmentHandler.__call__instead of unconditionally raisingValueError.sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_test.pycoveringQUIET,WARN, andRAISEonNotFoundfor both handlers.Note on
__init__existence checks (item 3 in #41345): Kept the eager admin checks in__init__unchanged to preserve existing fail-fast behavior verified bytest_permission_denied_online_store,test_raise_error_feature_store_not_found_online_store, andtest_vertex_ai_legacy_feature_store_invalid_featurestore. Happy to address that separately if maintainers prefer deferring it to__enter__.Testing
pytest sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_test.py -v(10 passed) andenrichment_test.py(11/11 total passed).google.cloud.aiplatformis unavailable (non-GCP environment).pylint --rcfile=sdks/python/.pylintrc(10.00/10),yapf --diff, andgit diff --cached --checkreport no issues.