Skip to content

Commit 4c28acc

Browse files
merged
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
1 parent 6688933 commit 4c28acc

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

sdk/python/feast/types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
from abc import ABC, abstractmethod
15+
from datetime import datetime, timezone
1516
from enum import Enum
1617
from typing import Dict, Union
1718

1819
import pyarrow
1920

2021
from feast.value_type import ValueType
21-
from feast.utils import _utc_now
2222

2323
PRIMITIVE_FEAST_TYPES_TO_VALUE_TYPES = {
2424
"INVALID": "UNKNOWN",
@@ -33,6 +33,10 @@
3333
}
3434

3535

36+
def _utc_now() -> datetime:
37+
return datetime.now(tz=timezone.utc)
38+
39+
3640
class ComplexFeastType(ABC):
3741
"""
3842
A ComplexFeastType represents a structured type that is recognized by Feast.
@@ -189,7 +193,7 @@ def __str__(self):
189193
Float32: pyarrow.float32(),
190194
Float64: pyarrow.float64(),
191195
# Note: datetime only supports microseconds https://github.com/python/cpython/blob/3.8/Lib/datetime.py#L1559
192-
UnixTimestamp: pyarrow.timestamp('us', tz=_utc_now().tzname()),
196+
UnixTimestamp: pyarrow.timestamp("us", tz=_utc_now().tzname()),
193197
}
194198

195199

sdk/python/feast/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ def _convert_arrow_to_proto(
232232
feature_view: "FeatureView",
233233
join_keys: Dict[str, ValueType],
234234
) -> List[Tuple[EntityKeyProto, Dict[str, ValueProto], datetime, Optional[datetime]]]:
235-
if isinstance(feature_view, OnDemandFeatureView):
235+
# This is a workaround for isinstance(feature_view, OnDemandFeatureView), which triggers a circular import
236+
if getattr(feature_view, "source_request_sources", None):
236237
return _convert_arrow_odfv_to_proto(table, feature_view, join_keys)
237238
else:
238239
return _convert_arrow_fv_to_proto(table, feature_view, join_keys)
@@ -1140,6 +1141,7 @@ def tags_str_to_dict(tags: str = "") -> dict[str, str]:
11401141
cast(tuple[str, str], tag.split(":", 1)) for tag in tags_list if ":" in tag
11411142
).items()
11421143
}
1144+
<<<<<<< HEAD
11431145

11441146

11451147
def _utc_now() -> datetime:
@@ -1192,3 +1194,5 @@ def _build_retrieve_online_document_record(
11921194
vector_value_proto,
11931195
distance_value_proto,
11941196
)
1197+
=======
1198+
>>>>>>> f97a28ca (checking in progress)

sdk/python/tests/unit/test_on_demand_python_transformation.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import re
33
import tempfile
4-
import time
54
import unittest
65
from datetime import datetime, timedelta
76
from typing import Any
@@ -162,6 +161,7 @@ def python_stored_writes_feature_view(
162161
],
163162
"current_datetime": [datetime.now() for _ in inputs["conv_rate"]],
164163
}
164+
print("running odfv transform")
165165
return output
166166

167167
with pytest.raises(TypeError):
@@ -283,27 +283,32 @@ def test_python_docs_demo(self):
283283
)
284284

285285
def test_stored_writes(self):
286-
entity_rows = [
286+
entity_rows_to_write = [
287287
{
288288
"driver_id": 1001,
289289
"conv_rate": 0.25,
290290
"acc_rate": 0.25,
291291
}
292292
]
293-
293+
entity_rows_to_read = [
294+
{
295+
"driver_id": 1001,
296+
}
297+
]
298+
print("storing odfv features")
294299
self.store.write_to_online_store(
295300
feature_view_name="python_stored_writes_feature_view",
296-
df=entity_rows,
301+
df=entity_rows_to_write,
297302
)
298-
time.sleep(1)
303+
print("reading odfv features")
299304
online_python_response = self.store.get_online_features(
300-
entity_rows=entity_rows,
305+
entity_rows=entity_rows_to_read,
301306
features=[
302307
"python_stored_writes_feature_view:conv_rate_plus_acc",
303308
"python_stored_writes_feature_view:current_datetime",
304309
],
305310
).to_dict()
306-
311+
print(online_python_response)
307312
assert sorted(list(online_python_response.keys())) == sorted(
308313
[
309314
"driver_id",

0 commit comments

Comments
 (0)