Skip to content

Commit 47998b9

Browse files
felixwang9817gitbook-bot
authored andcommitted
GitBook: [#317] Plugin testing
1 parent ccf3f8d commit 47998b9

File tree

2 files changed

+189
-154
lines changed

2 files changed

+189
-154
lines changed

docs/how-to-guides/adding-a-new-offline-store.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The process for using a custom offline store consists of 4 steps:
1515
3. Defining a `RetrievalJob` class for this offline store.
1616
4. Defining a `DataSource` class for the offline store
1717
5. Referencing the `OfflineStore` in a feature repo's `feature_store.yaml` file.
18+
6. Testing the `OfflineStore` class.
1819

1920
## 1. Defining an OfflineStore class
2021

@@ -65,7 +66,6 @@ There are two methods that deal with reading data from the offline stores`get_hi
6566
created_timestamp_column,
6667
start_date,
6768
end_date)
68-
6969
```
7070
{% endcode %}
7171

@@ -90,16 +90,14 @@ class CustomFileOfflineStoreConfig(FeastConfigBaseModel):
9090

9191
type: Literal["feast_custom_offline_store.file.CustomFileOfflineStore"] \
9292
= "feast_custom_offline_store.file.CustomFileOfflineStore"
93-
9493
```
9594
{% endcode %}
9695

9796
This configuration can be specified in the `feature_store.yaml` as follows:
9897

9998
{% code title="feature_repo/feature_store.yaml" %}
10099
```yaml
101-
type: feast_custom_offline_store.file.CustomFileOfflineStore
102-
100+
type: feast_custom_offline_store.file.CustomFileOfflineStore
103101
```
104102
{% endcode %}
105103
@@ -118,7 +116,6 @@ This configuration information is available to the methods of the OfflineStore,
118116
offline_store_config = config.offline_store
119117
assert isinstance(offline_store_config, CustomFileOfflineStoreConfig)
120118
store_type = offline_store_config.type
121-
122119
```
123120
{% endcode %}
124121

@@ -150,7 +147,6 @@ class CustomFileRetrievalJob(RetrievalJob):
150147
print("Getting a pandas DataFrame from a File is easy!")
151148
df = self.evaluation_function()
152149
return pyarrow.Table.from_pandas(df)
153-
154150
```
155151
{% endcode %}
156152

@@ -258,6 +254,28 @@ driver_hourly_stats_view = FeatureView(
258254
batch_source=driver_hourly_stats,
259255
...
260256
)
261-
262257
```
263258
{% endcode %}
259+
260+
## 6. Testing the OfflineStore class
261+
262+
Even if you have created the `OfflineStore` class in a separate repo, you can still test your implementation against the Feast test suite, as long as you have Feast as a submodule in your repo. In the Feast submodule, we can run all the unit tests with:
263+
264+
```
265+
make test
266+
```
267+
268+
The universal tests, which are integration tests specifically intended to test offline and online stores, can be run with:
269+
270+
```
271+
make test-python-universal
272+
```
273+
274+
The unit tests should succeed, but the universal tests will likely fail. The tests are parametrized based on the `FULL_REPO_CONFIGS` variable defined in `sdk/python/tests/integration/feature_repos/repo_configuration.py`. To overwrite these configurations, you can simply create your own file that contains a `FULL_REPO_CONFIGS`, and point Feast to that file by setting the environment variable `FULL_REPO_CONFIGS_MODULE` to point to that file. The main challenge there will be to write a `DataSourceCreator` for the offline store. In this repo, the file that overwrites `FULL_REPO_CONFIGS` is `feast_custom_offline_store/feast_tests.py`, so you would run
275+
276+
```
277+
export FULL_REPO_CONFIGS_MODULE='feast_custom_offline_store.feast_tests'
278+
make test-python-universal
279+
```
280+
281+
to test the offline store against the Feast universal tests. You should notice that some of the tests actually fail; this indicates that there is a mistake in the implementation of this offline store!

0 commit comments

Comments
 (0)