-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add feast init command Signed-off-by: Oleg Avdeev <oleg.v.avdeev@gmail.com> * tweak init Signed-off-by: Oleg Avdeev <oleg.v.avdeev@gmail.com>
- Loading branch information
Showing
8 changed files
with
173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
sdk/python/tests/driver_test_data.py → sdk/python/feast/driver_test_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# This module generates dummy data to be used for tests and examples. | ||
import numpy as np | ||
import pandas as pd | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This is an example feature definition file | ||
|
||
from google.protobuf.duration_pb2 import Duration | ||
|
||
from feast import Entity, Feature, FeatureView, ValueType | ||
from feast.data_source import FileSource | ||
|
||
# Read data from parquet files. Parquet is convenient for local development mode. For | ||
# production, you can use your favorite DWH, such as BigQuery. See Feast documentation | ||
# for more info. | ||
driver_hourly_stats = FileSource( | ||
path="%PARQUET_PATH%", | ||
event_timestamp_column="datetime", | ||
created_timestamp_column="created", | ||
) | ||
|
||
# Define an entity for the driver. You can think of entity as a primary key used to | ||
# fetch features. | ||
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id",) | ||
|
||
# Our parquet files contain sample data that includes a driver_id column, timestamps and | ||
# three feature column. Here we define a Feature View that will allow us to serve this | ||
# data to our model online. | ||
driver_hourly_stats_view = FeatureView( | ||
name="driver_hourly_stats", | ||
entities=["driver_id"], | ||
ttl=Duration(seconds=86400 * 1), | ||
features=[ | ||
Feature(name="conv_rate", dtype=ValueType.FLOAT), | ||
Feature(name="acc_rate", dtype=ValueType.FLOAT), | ||
Feature(name="avg_daily_trips", dtype=ValueType.INT64), | ||
], | ||
online=True, | ||
input=driver_hourly_stats, | ||
tags={}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import tempfile | ||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
|
||
from tests.cli.utils import CliRunner | ||
|
||
|
||
def test_repo_init() -> None: | ||
""" | ||
This test simply makes sure that you can run `feast apply && feast materialize` on | ||
the repo created by "feast init" without errors. | ||
""" | ||
runner = CliRunner() | ||
with tempfile.TemporaryDirectory() as repo_dir_name: | ||
repo_path = Path(repo_dir_name) | ||
result = runner.run(["init"], cwd=repo_path) | ||
assert result.returncode == 0 | ||
result = runner.run(["apply"], cwd=repo_path) | ||
assert result.returncode == 0 | ||
|
||
end_date = datetime.utcnow() | ||
start_date = end_date - timedelta(days=100) | ||
result = runner.run( | ||
["materialize", start_date.isoformat(), end_date.isoformat()], cwd=repo_path | ||
) | ||
assert result.returncode == 0 |