Skip to content

Commit

Permalink
fix: Import grpc only for type checking (#141)
Browse files Browse the repository at this point in the history
* fix: Import grpc only for type checking in errors.py

* chore: Disable warning for experimental SparkSource API

The commit disables a warning message for the experimental SparkSource API in the `spark_source.py` file. The warning was causing confusion for users, so it was decided to disable it. This change improves the user experience by removing unnecessary confusion.

* chore: Remove unused import warnings in spark_source.py

---------

Co-authored-by: Bhargav Dodla <[email protected]>
  • Loading branch information
EXPEbdodla and Bhargav Dodla authored Oct 2, 2024
1 parent 49a9c5f commit c2ed01c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
18 changes: 13 additions & 5 deletions sdk/python/feast/errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import importlib
import json
import logging
from typing import Any, List, Optional, Set
from typing import TYPE_CHECKING, Any, List, Optional, Set

from colorama import Fore, Style
from fastapi import status as HttpStatusCode
from grpc import StatusCode as GrpcStatusCode

if TYPE_CHECKING:
from grpc import StatusCode as GrpcStatusCode

from feast.field import Field

Expand All @@ -15,7 +17,9 @@
class FeastError(Exception):
pass

def grpc_status_code(self) -> GrpcStatusCode:
def grpc_status_code(self) -> "GrpcStatusCode":
from grpc import StatusCode as GrpcStatusCode

return GrpcStatusCode.INTERNAL

def http_status_code(self) -> int:
Expand Down Expand Up @@ -89,7 +93,9 @@ def __init__(self, ds_name: str):
class FeastObjectNotFoundException(FeastError):
pass

def grpc_status_code(self) -> GrpcStatusCode:
def grpc_status_code(self) -> "GrpcStatusCode":
from grpc import StatusCode as GrpcStatusCode

return GrpcStatusCode.NOT_FOUND

def http_status_code(self) -> int:
Expand Down Expand Up @@ -509,7 +515,9 @@ class FeastPermissionError(FeastError, PermissionError):
def __init__(self, details: str):
super().__init__(f"Permission error:\n{details}")

def grpc_status_code(self) -> GrpcStatusCode:
def grpc_status_code(self) -> "GrpcStatusCode":
from grpc import StatusCode as GrpcStatusCode

return GrpcStatusCode.PERMISSION_DENIED

def http_status_code(self) -> int:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import logging
import traceback
import warnings
from enum import Enum
from typing import Any, Callable, Dict, Iterable, Optional, Tuple

from feast import flags_helper
from feast.data_source import DataSource
from feast.errors import DataSourceNoNameException, DataSourceNotFoundException
from feast.infra.offline_stores.offline_utils import get_temp_entity_table_name
Expand Down Expand Up @@ -61,12 +59,13 @@ def __init__(
owner=owner,
)

if not flags_helper.is_test():
warnings.warn(
"The spark data source API is an experimental feature in alpha development. "
"This API is unstable and it could and most probably will be changed in the future.",
RuntimeWarning,
)
# We recommend using SparkSource for our users. So disabling this warning as this can cause confusion.
# if not flags_helper.is_test():
# warnings.warn(
# "The spark data source API is an experimental feature in alpha development. "
# "This API is unstable and it could and most probably will be changed in the future.",
# RuntimeWarning,
# )

self.spark_options = SparkOptions(
table=table,
Expand Down

0 comments on commit c2ed01c

Please sign in to comment.