Skip to content

Commit

Permalink
fix: grpc import error
Browse files Browse the repository at this point in the history
Signed-off-by: tokoko <[email protected]>
  • Loading branch information
tokoko committed Sep 18, 2024
1 parent 7535b40 commit b8bc6d7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/smoke_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: smoke-tests

on: [pull_request]
jobs:
unit-test-python:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11"]
os: [ ubuntu-latest ]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Get uv cache dir
id: uv-cache
run: |
echo "::set-output name=dir::$(uv cache dir)"
- name: uv cache
uses: actions/cache@v4
with:
path: ${{ steps.uv-cache.outputs.dir }}
key: ${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles(format('**/py{0}-ci-requirements.txt', env.PYTHON)) }}
- name: Install dependencies
run: make install-python-dependencies-uv
- name: Test Imports
run: pixi run python -c "from feast import cli"
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ build: protos build-java build-docker

# Python SDK

install-python-dependencies:
python -m piptools sync sdk/python/requirements/py$(PYTHON_VERSION)-requirements.txt
pip install --no-deps .
python setup.py build_python_protos --inplace

install-python-dependencies-uv:
uv pip sync --system sdk/python/requirements/py$(PYTHON_VERSION)-requirements.txt
uv pip install --system --no-deps .
python setup.py build_python_protos --inplace

install-python-dependencies-uv-venv:
uv pip sync sdk/python/requirements/py$(PYTHON_VERSION)-requirements.txt
uv pip install --no-deps .
python setup.py build_python_protos --inplace

install-python-ci-dependencies:
python -m piptools sync sdk/python/requirements/py$(PYTHON_VERSION)-ci-requirements.txt
pip install --no-deps -e .
Expand Down
12 changes: 7 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,7 @@
class FeastError(Exception):
pass

def grpc_status_code(self) -> GrpcStatusCode:
def grpc_status_code(self) -> "GrpcStatusCode":
return GrpcStatusCode.INTERNAL

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

def grpc_status_code(self) -> GrpcStatusCode:
def grpc_status_code(self) -> "GrpcStatusCode":
return GrpcStatusCode.NOT_FOUND

def http_status_code(self) -> int:
Expand Down Expand Up @@ -504,7 +506,7 @@ 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":
return GrpcStatusCode.PERMISSION_DENIED

def http_status_code(self) -> int:
Expand Down

0 comments on commit b8bc6d7

Please sign in to comment.