Skip to content

Commit

Permalink
added support for materialization_intervals in FeatureViews
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhargav Dodla committed Jul 19, 2023
1 parent 085b5e5 commit ee5fedf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Author: matcarlin@expediagroup.com
"""
import sys
from datetime import timedelta
from typing import Dict, List, Optional
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Tuple

import dill
from pydantic import BaseModel
Expand Down Expand Up @@ -66,6 +66,7 @@ class FeatureViewModel(BaseFeatureViewModel):
description: str
tags: Optional[Dict[str, str]]
owner: str
materialization_intervals: List[Tuple[datetime, datetime]] = []

def to_feature_view(self) -> FeatureView:
"""
Expand Down Expand Up @@ -102,6 +103,7 @@ def to_feature_view(self) -> FeatureView:
tags=self.tags if self.tags else None,
owner=self.owner,
)
feature_view.materialization_intervals = self.materialization_intervals

return feature_view

Expand Down Expand Up @@ -157,6 +159,7 @@ def from_feature_view(
description=feature_view.description,
tags=feature_view.tags if feature_view.tags else None,
owner=feature_view.owner,
materialization_intervals=feature_view.materialization_intervals,
)


Expand Down
6 changes: 5 additions & 1 deletion sdk/python/tests/unit/test_pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from datetime import timedelta
from datetime import datetime, timedelta
from typing import List

import pandas as pd
Expand Down Expand Up @@ -248,6 +248,10 @@ def test_idempotent_featureview_conversion():
],
source=spark_source,
)
python_obj.materialization_intervals = [
(datetime.now() - timedelta(days=10), datetime.now() - timedelta(days=9)),
(datetime.now(), datetime.now()),
]
pydantic_obj = FeatureViewModel.from_feature_view(python_obj)
converted_python_obj = pydantic_obj.to_feature_view()
assert python_obj == converted_python_obj
Expand Down

0 comments on commit ee5fedf

Please sign in to comment.