Skip to content

Commit

Permalink
Fix formating
Browse files Browse the repository at this point in the history
Signed-off-by: Judah Rand <17158624+judahrand@users.noreply.github.com>
  • Loading branch information
judahrand committed Dec 8, 2021
1 parent f149b16 commit c84a6fc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
4 changes: 3 additions & 1 deletion sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ def _python_value_to_proto_value(feast_value_type: ValueType, value: Any) -> Pro
if isinstance(sub_value, datetime):
converted_value.append(int(sub_value.timestamp()))
elif isinstance(sub_value, date):
converted_value.append(int(datetime(*sub_value.timetuple()[:6]).timestamp()))
converted_value.append(
int(datetime(*sub_value.timetuple()[:6]).timestamp())
)
elif isinstance(sub_value, Timestamp):
converted_value.append(int(sub_value.ToSeconds()))
else:
Expand Down
16 changes: 14 additions & 2 deletions sdk/python/tests/data/data_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@ def get_feature_values_for_dtype(
"float": [1.0, None, 3.0, 4.0, 5.0],
"string": ["1", None, "3", "4", "5"],
"bool": [True, None, False, True, False],
"datetime": [datetime(2020, 1, 2), None, datetime(2020, 1, 3), datetime(2020, 1, 4), datetime(2020, 1, 5)],
"date": [date(2020, 1, 2), None, date(2020, 1, 3), date(2020, 1, 4), date(2020, 1, 5)],
"datetime": [
datetime(2020, 1, 2),
None,
datetime(2020, 1, 3),
datetime(2020, 1, 4),
datetime(2020, 1, 5),
],
"date": [
date(2020, 1, 2),
None,
date(2020, 1, 3),
date(2020, 1, 4),
date(2020, 1, 5),
],
}
non_list_val = dtype_map[dtype]
if is_list:
Expand Down
26 changes: 13 additions & 13 deletions sdk/python/tests/integration/registration/test_universal_types.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from dataclasses import dataclass
from datetime import date, datetime, timedelta
from typing import List
import feast

import numpy as np
import pandas as pd
import pytest
import pyarrow as pa
import pyarrow.types
import pytest

import feast
from feast.infra.offline_stores.offline_store import RetrievalJob
from feast.value_type import ValueType
from tests.data.data_creator import create_dataset
Expand All @@ -29,7 +29,7 @@ def populate_test_configs(offline: bool):
(ValueType.STRING, "float"),
(ValueType.STRING, "bool"),
(ValueType.INT32, "datetime"),
(ValueType.INT32, "date")
(ValueType.INT32, "date"),
]
configs: List[TypeTestConfig] = []
for test_repo_config in FULL_REPO_CONFIGS:
Expand Down Expand Up @@ -156,11 +156,17 @@ def test_feature_get_historical_features_types_match(offline_types_test_fixtures
environment, config, data_source, fv = offline_types_test_fixtures

# TODO: improve how FileSource handles Arrow schema inference.
if config.feature_dtype == 'date' and config.feature_is_list and config.has_empty_list and isinstance(data_source, feast.FileSource):
if (
config.feature_dtype == "date"
and config.feature_is_list
and config.has_empty_list
and isinstance(data_source, feast.FileSource)
):
pytest.xfail(
"`feast.FileSource` cannot deal with returning all empty "
"`List[date]` features to Arrow as it infers the schema "
"from the Pandas Dataframe which does not have a dtype to represent `date`")
"from the Pandas Dataframe which does not have a dtype to represent `date`"
)

fs = environment.feature_store
fv = create_feature_view(
Expand Down Expand Up @@ -309,14 +315,8 @@ def assert_feature_list_types(
bool,
np.bool_,
), # Can be `np.bool_` if from `np.array` rather that `list`
"datetime": (
datetime,
np.datetime64,
),
"date": (
date,
np.datetime64
)
"datetime": (datetime, np.datetime64,),
"date": (date, np.datetime64),
}
expected_dtype = feature_list_dtype_to_expected_historical_feature_list_dtype[
feature_dtype
Expand Down

0 comments on commit c84a6fc

Please sign in to comment.