You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FSTORE-1672] Allow multiple on-demand features to be returned from an on-demand transformation function and allow passing of local variables to a transformation function (logicalclocks#439)
Copy file name to clipboardexpand all lines: docs/user_guides/fs/feature_group/on_demand_transformations.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,13 @@
5
5
## On Demand Transformation Function Creation
6
6
7
7
8
-
An on-demand transformation function may be created by associating a [transformation function](../transformation_functions.md) with a feature group. Each on-demand transformation function generates a single on-demand feature, which, by default, is assigned the same name as the associated transformation function. For instance, in the example below, the on-demand transformation function `transaction_age` produces an on-demand feature named transaction_age. Alternatively, the name of the resulting on-demand feature can be explicitly defined using the [`alias`](../transformation_functions.md#specifying-output-features–names-for-transformation-functions) function.
9
-
10
-
It is important to note that only one-to-one or many-to-one transformation functions are compatible with the creation of on-demand transformation functions.
8
+
An on-demand transformation function may be created by associating a [transformation function](../transformation_functions.md) with a feature group. Each on-demand transformation function can generate one or multiple on-demand features. If the on-demand transformation function returns a single feature, it is automatically assigned the same name as the transformation function. However, if it returns multiple features, they are by default named using the format `functionName_outputColumnNumber`. For instance, in the example below, the on-demand transformation function `transaction_age` produces an on-demand feature named `transaction_age` and the on-demand transformation function `stripped_strings` produces the on-demand features names `stripped_strings_0` and `stripped_strings_1`. Alternatively, the name of the resulting on-demand feature can be explicitly defined using the [`alias`](../transformation_functions.md#specifying-output-features–names-for-transformation-functions) function.
11
9
12
10
!!! warning "On-demand transformation"
13
11
All on-demand transformation functions attached to a feature group must have unique names and, in contrast to model-dependent transformations, they do not have access to training dataset statistics.
14
12
15
13
Each on-demand transformation function can map specific features to its arguments by explicitly providing their names as arguments to the transformation function. If no feature names are provided, the transformation function will default to using features that match the name of the transformation function's argument.
16
14
17
-
18
-
19
15
=== "Python"
20
16
!!! example "Creating on-demand transformation functions."
21
17
```python
@@ -24,14 +20,18 @@ Each on-demand transformation function can map specific features to its argument
It is important to note that in addition to the filters defined in feature view, [extra filters](./training-data.md#Extra-filters) will be applied if they are defined in the given training dataset version.
56
+
It is important to note that in addition to the filters defined in feature view, [extra filters](./training-data.md#Extra-filters) will be applied if they are defined in the given training dataset version.
57
+
58
+
59
+
## Passing Context Variables to Transformation Functions
60
+
After [defining a transformation function using a context variable](../transformation_functions.md#passing-context-variables-to-transformation-function), you can pass the necessary context variables through the `transformation_context` parameter when fetching batch data.
61
+
62
+
63
+
==="Python"
64
+
!!! example "Passing context variables while fetching batch data."
65
+
```python
66
+
# Passing context variable to IN-MEMORY Training Dataset.
Copy file name to clipboardexpand all lines: docs/user_guides/fs/feature_view/feature-vectors.md
+13
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,19 @@ You can also use the parameter to provide values for all the features which are
191
191
)
192
192
```
193
193
194
+
## Passing Context Variables to Transformation Functions
195
+
After [defining a transformation function using a context variable](../transformation_functions.md#passing-context-variables-to-transformation-function), you can pass the required context variables using the `transformation_context` parameter when fetching the feature vectors.
196
+
197
+
=== "Python"
198
+
!!! example "Passing context variables while fetching batch data."
199
+
```python
200
+
# Passing context variable to IN-MEMORY Training Dataset.
201
+
batch_data = feature_view.get_feature_vectors(
202
+
entry = [{ "pk1": 1 }],
203
+
transformation_context={"context_parameter":10}
204
+
)
205
+
```
206
+
194
207
## Choose the right Client
195
208
196
209
The Online Store can be accessed via the **Python** or **Java** client allowing you to use your language of choice to connect to the Online Store. Additionally, the Python client provides two different implementations to fetch data: **SQL** or **REST**. The SQL client is the default implementation. It requires a direct SQL connection to your RonDB cluster and uses python asyncio to offer high performance even when your Feature View rows involve querying multiple different tables. The REST client is an alternative implementation connecting to [RonDB Feature Vector Server](./feature-server.md). Perfect if you want to avoid exposing ports of your database cluster directly to clients. This implementation is available as of Hopsworks 3.7.
## Passing Context Variables to Transformation Functions
98
+
Once you have [defined a transformation function using a context variable](../transformation_functions.md#passing-context-variables-to-transformation-function), you can pass the required context variables using the `transformation_context` parameter when generating IN-MEMORY training data or materializing a training dataset.
99
+
100
+
!!! note
101
+
Passing context variables for materializing a training dataset is only supported in the PySpark Kernel.
102
+
103
+
104
+
==="Python"
105
+
!!! example "Passing context variables while creating training data."
106
+
```python
107
+
# Passing context variable to IN-MEMORY Training Dataset.
### Passing context variables to transformation function
232
+
233
+
The `context` keyword argument can be defined in a transformation function to access shared context variables. These variables contain common data used across transformation functions. By including the context argument, you can pass the necessary data as a dictionary into the into the `context` argument of the transformation function during [training dataset creation](feature_view/training-data.md#passing-context-variables-to-transformation-functions) or [feature vector retrieval](feature_view/feature-vectors.md#passing-context-variables-to-transformation-functions) or [batch data retrieval](feature_view/batch-data.md#passing-context-variables-to-transformation-functions).
234
+
235
+
236
+
=== "Python"
237
+
!!! example "Creation of a transformation function in Hopsworks that accepts context variables"
0 commit comments