17
17
18
18
from typing import List , Optional , Union
19
19
20
- from hsfs import (
21
- client ,
22
- feature_view ,
23
- training_dataset ,
24
- transformation_function_attached ,
25
- )
20
+ from hsfs import client , feature_view , training_dataset , transformation_function
26
21
from hsfs .client .exceptions import RestAPIError
27
22
from hsfs .constructor import query , serving_prepared_statement
28
23
from hsfs .core import explicit_provenance , job , training_dataset_job_conf
@@ -86,13 +81,28 @@ def update(self, feature_view_obj: feature_view.FeatureView) -> None:
86
81
data = feature_view_obj .json (),
87
82
)
88
83
89
- def get_by_name (self , name : str ) -> feature_view .FeatureView :
84
+ def get_by_name (self , name : str ) -> List [feature_view .FeatureView ]:
85
+ """
86
+ Get a feature view from the backend using its name.
87
+
88
+ # Arguments
89
+ name `str`: Name of the feature view.
90
+
91
+ # Returns
92
+ `List[FeatureView]`: A list that contains all version of the feature view.
93
+
94
+ # Raises
95
+ `RestAPIError`: If the feature view cannot be found from the backend.
96
+ `ValueError`: If the feature group associated with the feature view cannot be found.
97
+ """
90
98
path = self ._base_path + [name ]
91
99
try :
92
100
return [
93
101
feature_view .FeatureView .from_response_json (fv )
94
102
for fv in self ._client ._send_request (
95
- self ._GET , path , {"expand" : ["query" , "features" ]}
103
+ self ._GET ,
104
+ path ,
105
+ {"expand" : ["query" , "features" , "transformationfunctions" ]},
96
106
)["items" ]
97
107
]
98
108
except RestAPIError as e :
@@ -106,11 +116,27 @@ def get_by_name(self, name: str) -> feature_view.FeatureView:
106
116
raise e
107
117
108
118
def get_by_name_version (self , name : str , version : int ) -> feature_view .FeatureView :
119
+ """
120
+ Get a feature view form the backend using both name and version
121
+
122
+ # Arguments
123
+ name `str`: Name of feature view.
124
+ version `version`: Version of the feature view.
125
+
126
+ # Returns
127
+ `FeatureView`
128
+
129
+ # Raises
130
+ `RestAPIError`: If the feature view cannot be found from the backend.
131
+ `ValueError`: If the feature group associated with the feature view cannot be found.
132
+ """
109
133
path = self ._base_path + [name , self ._VERSION , version ]
110
134
try :
111
135
return feature_view .FeatureView .from_response_json (
112
136
self ._client ._send_request (
113
- self ._GET , path , {"expand" : ["query" , "features" ]}
137
+ self ._GET ,
138
+ path ,
139
+ {"expand" : ["query" , "features" , "transformationfunctions" ]},
114
140
)
115
141
)
116
142
except RestAPIError as e :
@@ -190,12 +216,23 @@ def get_serving_prepared_statement(
190
216
191
217
def get_attached_transformation_fn (
192
218
self , name : str , version : int
193
- ) -> Union [
194
- "transformation_function_attached.TransformationFunctionAttached" ,
195
- List ["transformation_function_attached.TransformationFunctionAttached" ],
196
- ]:
219
+ ) -> List ["transformation_function.TransformationFunction" ]:
220
+ """
221
+ Get transformation functions attached to a feature view form the backend
222
+
223
+ # Arguments
224
+ name `str`: Name of feature view.
225
+ version `ìnt`: Version of feature view.
226
+
227
+ # Returns
228
+ `List[TransformationFunction]` : List of transformation functions attached to the feature view.
229
+
230
+ # Raises
231
+ `RestAPIError`: If the feature view cannot be found from the backend.
232
+ `ValueError`: If the feature group associated with the feature view cannot be found.
233
+ """
197
234
path = self ._base_path + [name , self ._VERSION , version , self ._TRANSFORMATION ]
198
- return transformation_function_attached . TransformationFunctionAttached .from_response_json (
235
+ return transformation_function . TransformationFunction .from_response_json (
199
236
self ._client ._send_request ("GET" , path )
200
237
)
201
238
0 commit comments