Skip to content

Commit

Permalink
Add created timestamp for feature views (#1952)
Browse files Browse the repository at this point in the history
* Updating roadmap + hero image (#1950)

* Update hero image

Signed-off-by: Danny Chiao <danny@tecton.ai>

* Fix roadmap extra line

Signed-off-by: Danny Chiao <danny@tecton.ai>
Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* ✨ Add created timestamp for feature view

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* 🎨 Adding created timestamp to base feature view and on demand feature view

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* 🚨 Fix import

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* 🔥 Remove unused import

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* 🎨 Add read/write created timestamp to ODFV

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

* 🚨 Fix isort lint

Signed-off-by: Amom Mendes <amommendes@hotmail.com>

Co-authored-by: Danny Chiao <d.chiao@gmail.com>
Co-authored-by: Achal Shah <achals@gmail.com>
  • Loading branch information
3 people authored Jan 6, 2022
1 parent 6c09bc4 commit ad3ea8d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ The list below contains the functionality that contributors are planning to deve
* We welcome contribution to all items in the roadmap!
* Want to influence our roadmap and prioritization? Submit your feedback to [this form](https://docs.google.com/forms/d/e/1FAIpQLSfa1nRQ0sKz-JEFnMMCi4Jseag\_yDssO\_3nV9qMfxfrkil-wA/viewform).
* Want to speak to a Feast contributor? We are more than happy to jump on a call. Please schedule a time using [Calendly](https://calendly.com/d/x2ry-g5bb/meet-with-feast-team).

* **Data Sources**
* [x] [Redshift source](https://docs.feast.dev/reference/data-sources/redshift)
* [x] [BigQuery source](https://docs.feast.dev/reference/data-sources/bigquery)
Expand Down
1 change: 1 addition & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The list below contains the functionality that contributors are planning to deve
* We welcome contribution to all items in the roadmap!
* Want to influence our roadmap and prioritization? Submit your feedback to [this form](https://docs.google.com/forms/d/e/1FAIpQLSfa1nRQ0sKz-JEFnMMCi4Jseag\_yDssO\_3nV9qMfxfrkil-wA/viewform).
* Want to speak to a Feast contributor? We are more than happy to jump on a call. Please schedule a time using [Calendly](https://calendly.com/d/x2ry-g5bb/meet-with-feast-team).

* **Data Sources**
* [x] [Redshift source](https://docs.feast.dev/reference/data-sources/redshift)
* [x] [BigQuery source](https://docs.feast.dev/reference/data-sources/bigquery)
Expand Down
9 changes: 9 additions & 0 deletions protos/feast/core/OnDemandFeatureView.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ option go_package = "github.com/feast-dev/feast/sdk/go/protos/feast/core";
option java_outer_classname = "OnDemandFeatureViewProto";
option java_package = "feast.proto.core";

import "google/protobuf/timestamp.proto";
import "feast/core/FeatureView.proto";
import "feast/core/Feature.proto";
import "feast/core/DataSource.proto";

message OnDemandFeatureView {
// User-specified specifications of this feature view.
OnDemandFeatureViewSpec spec = 1;
OnDemandFeatureViewMeta meta = 2;
}

message OnDemandFeatureViewSpec {
Expand All @@ -45,6 +47,13 @@ message OnDemandFeatureViewSpec {
map<string, OnDemandInput> inputs = 4;

UserDefinedFunction user_defined_function = 5;


}

message OnDemandFeatureViewMeta {
// Time where this Feature View is created
google.protobuf.Timestamp created_timestamp = 1;
}

message OnDemandInput {
Expand Down
4 changes: 3 additions & 1 deletion sdk/python/feast/base_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
import warnings
from abc import ABC, abstractmethod
from typing import List, Type
from datetime import datetime
from typing import List, Optional, Type

from google.protobuf.json_format import MessageToJson
from proto import Message
Expand All @@ -32,6 +33,7 @@ def __init__(self, name: str, features: List[Feature]):
self._name = name
self._features = features
self._projection = FeatureViewProjection.from_definition(self)
self.created_timestamp: Optional[datetime] = None

@property
def name(self) -> str:
Expand Down
1 change: 0 additions & 1 deletion sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class FeatureView(BaseFeatureView):
input: DataSource
batch_source: DataSource
stream_source: Optional[DataSource] = None
created_timestamp: Optional[datetime] = None
last_updated_timestamp: Optional[datetime] = None
materialization_intervals: List[Tuple[datetime, datetime]]

Expand Down
11 changes: 10 additions & 1 deletion sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
OnDemandFeatureView as OnDemandFeatureViewProto,
)
from feast.protos.feast.core.OnDemandFeatureView_pb2 import (
OnDemandFeatureViewMeta,
OnDemandFeatureViewSpec,
OnDemandInput,
)
Expand Down Expand Up @@ -90,6 +91,9 @@ def to_proto(self) -> OnDemandFeatureViewProto:
Returns:
A OnDemandFeatureViewProto protobuf.
"""
meta = OnDemandFeatureViewMeta()
if self.created_timestamp:
meta.created_timestamp.FromDatetime(self.created_timestamp)
inputs = {}
for input_ref, fv in self.input_feature_views.items():
inputs[input_ref] = OnDemandInput(feature_view=fv.to_proto())
Expand All @@ -107,7 +111,7 @@ def to_proto(self) -> OnDemandFeatureViewProto:
),
)

return OnDemandFeatureViewProto(spec=spec)
return OnDemandFeatureViewProto(spec=spec, meta=meta)

@classmethod
def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
Expand Down Expand Up @@ -155,6 +159,11 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
on_demand_feature_view_obj
)

if on_demand_feature_view_proto.meta.HasField("created_timestamp"):
on_demand_feature_view_obj.created_timestamp = (
on_demand_feature_view_proto.meta.created_timestamp.ToDatetime()
)

return on_demand_feature_view_obj

def get_request_data_schema(self) -> Dict[str, ValueType]:
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/feast/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ def apply_feature_view(
commit: Whether the change should be persisted immediately
"""
feature_view.ensure_valid()
if not feature_view.created_timestamp:
feature_view.created_timestamp = datetime.now()
feature_view_proto = feature_view.to_proto()
feature_view_proto.spec.project = project
self._prepare_registry_for_changes()
Expand Down

0 comments on commit ad3ea8d

Please sign in to comment.