-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Initial commit targetting grpc registry server #4458
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3e07339
initial commit targetting grpc registry server
dmartinol e833ff1
refactor: Introduced base class FeastError for all Feast exceptions (…
dmartinol d94c9ac
initial commit targetting grpc registry server
dmartinol acd9763
fixed merge error
dmartinol 592c1ce
initial commit targetting grpc registry server
dmartinol 73070ca
fixed merge error
dmartinol 24661df
integrated comment
dmartinol 400615a
Merge branch 'master' into issue-4392
dmartinol 618cb00
Merge branch 'feast-dev:master' into issue-4392
dmartinol 50306c1
moved imports as per comment
dmartinol 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import grpc | ||
|
|
||
| from feast.errors import FeastError | ||
|
|
||
|
|
||
| def exception_wrapper(behavior, request, context): | ||
| try: | ||
| return behavior(request, context) | ||
| except grpc.RpcError as e: | ||
| context.abort(e.code(), e.details()) | ||
| except FeastError as e: | ||
| context.abort( | ||
| e.grpc_status_code(), | ||
| e.to_error_detail(), | ||
| ) | ||
|
|
||
|
|
||
| class ErrorInterceptor(grpc.ServerInterceptor): | ||
| def intercept_service(self, continuation, handler_call_details): | ||
| handler = continuation(handler_call_details) | ||
| if handler is None: | ||
| return None | ||
|
|
||
| if handler.unary_unary: | ||
| return grpc.unary_unary_rpc_method_handler( | ||
| lambda req, ctx: exception_wrapper(handler.unary_unary, req, ctx), | ||
| request_deserializer=handler.request_deserializer, | ||
| response_serializer=handler.response_serializer, | ||
| ) | ||
| elif handler.unary_stream: | ||
| return grpc.unary_stream_rpc_method_handler( | ||
| lambda req, ctx: exception_wrapper(handler.unary_stream, req, ctx), | ||
| request_deserializer=handler.request_deserializer, | ||
| response_serializer=handler.response_serializer, | ||
| ) | ||
| elif handler.stream_unary: | ||
| return grpc.stream_unary_rpc_method_handler( | ||
| lambda req, ctx: exception_wrapper(handler.stream_unary, req, ctx), | ||
| request_deserializer=handler.request_deserializer, | ||
| response_serializer=handler.response_serializer, | ||
| ) | ||
| elif handler.stream_stream: | ||
| return grpc.stream_stream_rpc_method_handler( | ||
| lambda req, ctx: exception_wrapper(handler.stream_stream, req, ctx), | ||
| request_deserializer=handler.request_deserializer, | ||
| response_serializer=handler.response_serializer, | ||
| ) | ||
| return handler |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import re | ||
|
|
||
| import assertpy | ||
|
|
||
| import feast.errors as errors | ||
|
|
||
|
|
||
| def test_error_error_detail(): | ||
| e = errors.FeatureViewNotFoundException("abc") | ||
|
|
||
| d = e.to_error_detail() | ||
|
|
||
| assertpy.assert_that(d).is_not_none() | ||
| assertpy.assert_that(d).contains('"module": "feast.errors"') | ||
| assertpy.assert_that(d).contains('"class": "FeatureViewNotFoundException"') | ||
| assertpy.assert_that(re.search(r"abc", d)).is_true() | ||
|
|
||
| converted_e = errors.FeastError.from_error_detail(d) | ||
| assertpy.assert_that(converted_e).is_not_none() | ||
| assertpy.assert_that(str(converted_e)).is_equal_to(str(e)) | ||
| assertpy.assert_that(repr(converted_e)).is_equal_to(repr(e)) | ||
|
|
||
|
|
||
| def test_invalid_error_error_detail(): | ||
| e = errors.FeastError.from_error_detail("invalid") | ||
| assertpy.assert_that(e).is_none() |
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.
These are standard lib libraries, why not import top-level?