Skip to content
Merged
Prev Previous commit
Next Next commit
make format
Signed-off-by: Achal Shah <achals@gmail.com>
  • Loading branch information
achals committed Jun 15, 2021
commit f79a3b9cdd41b869de5f885906eb569f0b462799
6 changes: 3 additions & 3 deletions sdk/python/feast/infra/online_stores/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union

import mmh3
from pydantic import PositiveInt, StrictStr
from pydantic.typing import Literal

from feast import Entity, FeatureTable, utils
from feast.feature_view import FeatureView
from feast.infra.key_encoding_utils import serialize_entity_key
from feast.infra.online_stores.online_store import OnlineStore
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import RepoConfig, FeastConfigBaseModel
from pydantic import StrictStr, PositiveInt
from pydantic.typing import Literal
from feast.repo_config import FeastConfigBaseModel, RepoConfig

try:
from google.auth.exceptions import DefaultCredentialsError
Expand Down
5 changes: 1 addition & 4 deletions sdk/python/feast/infra/online_stores/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
from feast.infra.online_stores.online_store import OnlineStore
from feast.protos.feast.storage.Redis_pb2 import RedisKeyV2 as RedisKeyProto
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
from feast.repo_config import (
OnlineStoreConfig,
RedisOnlineStoreConfig,
)
from feast.repo_config import OnlineStoreConfig, RedisOnlineStoreConfig


def get_online_store_from_config(
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/feast/infra/online_stores/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

import pytz
from pydantic import StrictStr
from pydantic.schema import Literal

from feast import Entity, FeatureTable
from feast.feature_view import FeatureView
from feast.infra.key_encoding_utils import serialize_entity_key
from feast.infra.online_stores.online_store import OnlineStore
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import RepoConfig, FeastConfigBaseModel
from pydantic import StrictStr
from pydantic.schema import Literal
from feast.repo_config import FeastConfigBaseModel, RepoConfig


class SqliteOnlineStoreConfig(FeastConfigBaseModel):
Expand Down
4 changes: 1 addition & 3 deletions sdk/python/feast/infra/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ def get_provider(config: RepoConfig, repo_path: Path) -> Provider:
except AttributeError:
# This can only be one type of error, when class_name attribute does not exist in the module
# So we don't have to include the original exception here
raise errors.FeastClassImportError(
module_name, class_name
) from None
raise errors.FeastClassImportError(module_name, class_name) from None

return ProviderCls(config, repo_path)

Expand Down
34 changes: 14 additions & 20 deletions sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
import importlib
from enum import Enum
from pathlib import Path
from typing import TypeVar, Generic, Any
from typing import Any, TypeVar

import yaml
from pydantic import (
BaseModel,
StrictInt,
StrictStr,
ValidationError,
root_validator,
)
from pydantic import BaseModel, StrictInt, StrictStr, ValidationError, root_validator
from pydantic.error_wrappers import ErrorWrapper
from pydantic.typing import Dict, Literal, Optional, Union

from feast.telemetry import log_exceptions
from feast import errors

from feast.telemetry import log_exceptions

# This dict exists so that:
# - existing values for the online store type in featurestore.yaml files continue to work in a backwards compatible way
# - first party and third party implementations can use the same class loading code path.
ONLINE_CONFIG_CLASS_FOR_TYPE = {
'sqlite': 'feast.infra.online_stores.sqlite.SqliteOnlineStore',
'datastore': 'feast.infra.online_stores.datastore.DatastoreOnlineStore'
"sqlite": "feast.infra.online_stores.sqlite.SqliteOnlineStore",
"datastore": "feast.infra.online_stores.datastore.DatastoreOnlineStore",
}


Expand All @@ -43,7 +36,7 @@ class Config:
extra = "forbid"


OnlineT = TypeVar('OnlineT', bound=FeastConfigBaseModel)
OnlineT = TypeVar("OnlineT", bound=FeastConfigBaseModel)


class RedisType(str, Enum):
Expand Down Expand Up @@ -237,7 +230,7 @@ def get_online_config_from_type(online_store_type: str):
online_store_type = ONLINE_CONFIG_CLASS_FOR_TYPE[online_store_type]
module_name, class_name = online_store_type.rsplit(".", 1)

if not class_name.endswith('OnlineStore'):
if not class_name.endswith("OnlineStore"):
raise errors.FeastOnlineStoreConfigInvalidName(class_name)
config_class_name = f"{class_name}Config"

Expand All @@ -248,7 +241,9 @@ def get_online_config_from_type(online_store_type: str):
# The original exception can be anything - either module not found,
# or any other kind of error happening during the module import time.
# So we should include the original error as well in the stack trace.
raise errors.FeastModuleImportError(module_name, module_type="OnlineStore") from e
raise errors.FeastModuleImportError(
module_name, module_type="OnlineStore"
) from e

# Try getting the provider class definition
try:
Expand All @@ -270,11 +265,10 @@ def load_repo_config(repo_path: Path) -> RepoConfig:
try:
c = RepoConfig(**raw_config)
c.repo_path = repo_path
online_config_class = get_online_config_from_type(c.dict()['online_store']['type'])
c.online_store = online_config_class(**c.dict()['online_store'])
online_config_class = get_online_config_from_type(
c.dict()["online_store"]["type"]
)
c.online_store = online_config_class(**c.dict()["online_store"])
return c
except ValidationError as e:
raise FeastConfigError(e, config_path)



12 changes: 6 additions & 6 deletions sdk/python/tests/test_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
from tempfile import mkstemp

import pytest
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from pytest_lazyfixture import lazy_fixture
from tests.utils.data_source_utils import (
prep_file_source,
simple_bq_source_using_query_arg,
simple_bq_source_using_table_ref_arg,
)

from feast.data_format import ParquetFormat
from feast.data_source import FileSource
from feast.entity import Entity
from feast.feature import Feature
from feast.feature_store import FeatureStore
from feast.feature_view import FeatureView
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.protos.feast.types import Value_pb2 as ValueProto
from feast.repo_config import RepoConfig
from feast.value_type import ValueType
from tests.utils.data_source_utils import (
prep_file_source,
simple_bq_source_using_query_arg,
simple_bq_source_using_table_ref_arg,
)


@pytest.fixture
Expand Down
7 changes: 2 additions & 5 deletions sdk/python/tests/test_historical_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import pandas as pd
import pytest
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from google.cloud import bigquery
from pandas.testing import assert_frame_equal
from pytz import utc
Expand All @@ -21,11 +20,9 @@
from feast.feature import Feature
from feast.feature_store import FeatureStore
from feast.feature_view import FeatureView
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.infra.provider import DEFAULT_ENTITY_DF_EVENT_TIMESTAMP_COL
from feast.repo_config import (
BigQueryOfflineStoreConfig,
RepoConfig,
)
from feast.repo_config import BigQueryOfflineStoreConfig, RepoConfig
from feast.value_type import ValueType

np.random.seed(0)
Expand Down
10 changes: 3 additions & 7 deletions sdk/python/tests/test_offline_online_store_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import pandas as pd
import pytest
from feast.infra.online_stores.datastore import DatastoreOnlineStoreConfig
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from google.cloud import bigquery
from pytz import timezone, utc

Expand All @@ -19,11 +17,9 @@
from feast.feature import Feature
from feast.feature_store import FeatureStore
from feast.feature_view import FeatureView
from feast.repo_config import (
RedisOnlineStoreConfig,
RedisType,
RepoConfig,
)
from feast.infra.online_stores.datastore import DatastoreOnlineStoreConfig
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.repo_config import RedisOnlineStoreConfig, RedisType, RepoConfig
from feast.value_type import ValueType


Expand Down
1 change: 0 additions & 1 deletion sdk/python/tests/test_repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from textwrap import dedent
from typing import Optional

import pytest
from feast.repo_config import FeastConfigError, load_repo_config


Expand Down