Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add created timestamp for feature views #1952

Merged
merged 11 commits into from
Jan 6, 2022
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,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
achals marked this conversation as resolved.
Show resolved Hide resolved

@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 @@ -74,7 +74,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 @@ -306,6 +306,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