We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contactedHave 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
| @@ -0,0 +1,49 @@ | ||
| import logging | ||
| from functools import wraps | ||
|
|
||
| import pyarrow.flight as fl | ||
|
|
||
| from feast.errors import FeastError | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def arrow_client_error_handling_decorator(func): | ||
| @wraps(func) | ||
| def wrapper(*args, **kwargs): | ||
| try: | ||
| return func(*args, **kwargs) | ||
| except Exception as e: | ||
| mapped_error = FeastError.from_error_detail(_get_exception_data(e.args[0])) | ||
| if mapped_error is not None: | ||
| raise mapped_error | ||
| raise e | ||
|
|
||
| return wrapper | ||
|
|
||
|
|
||
| def arrow_server_error_handling_decorator(func): | ||
| @wraps(func) | ||
| def wrapper(*args, **kwargs): | ||
| try: | ||
| return func(*args, **kwargs) | ||
| except Exception as e: | ||
| if isinstance(e, FeastError): | ||
| raise fl.FlightError(e.to_error_detail()) | ||
|
|
||
| return wrapper | ||
|
|
||
|
|
||
| def _get_exception_data(except_str) -> str: | ||
| substring = "Flight error: " | ||
|
|
||
| # Find the starting index of the substring | ||
| position = except_str.find(substring) | ||
| end_json_index = except_str.find("}") | ||
|
|
||
| if position != -1 and end_json_index != -1: | ||
| # Extract the part of the string after the substring | ||
| result = except_str[position + len(substring) : end_json_index + 1] | ||
| return result | ||
|
|
||
| return "" | ||
Uh oh!
There was an error while loading. Please reload this page.