Skip to content

Commit 6e1bb35

Browse files
committed
udpated attribute names as per review comments
1 parent 798e0ac commit 6e1bb35

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

python/hsfs/core/vector_server.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,7 @@ def apply_on_demand_transformations(
10011001
_logger.debug("Applying On-Demand transformation functions.")
10021002
for tf in self._on_demand_transformation_functions:
10031003
if (
1004-
tf.hopsworks_udf.execution_mode.get_current_execution_mode(
1005-
inference=True
1006-
)
1004+
tf.hopsworks_udf.execution_mode.get_current_execution_mode(online=True)
10071005
== UDFExecutionMode.PANDAS
10081006
):
10091007
# Check if feature provided as request parameter if not get it from retrieved feature vector.
@@ -1028,13 +1026,11 @@ def apply_on_demand_transformations(
10281026
for feature in tf.hopsworks_udf.transformation_features
10291027
]
10301028

1031-
on_demand_feature = tf.hopsworks_udf.get_udf(inference=True)(
1029+
on_demand_feature = tf.hopsworks_udf.get_udf(online=True)(
10321030
*features
10331031
) # Get only python compatible UDF irrespective of engine
10341032
if (
1035-
tf.hopsworks_udf.execution_mode.get_current_execution_mode(
1036-
inference=True
1037-
)
1033+
tf.hopsworks_udf.execution_mode.get_current_execution_mode(online=True)
10381034
== UDFExecutionMode.PANDAS
10391035
):
10401036
rows[on_demand_feature.name] = on_demand_feature.values[0]
@@ -1046,9 +1042,7 @@ def apply_model_dependent_transformations(self, rows: Union[dict, pd.DataFrame])
10461042
_logger.debug("Applying Model-Dependent transformation functions.")
10471043
for tf in self.model_dependent_transformation_functions:
10481044
if (
1049-
tf.hopsworks_udf.execution_mode.get_current_execution_mode(
1050-
inference=True
1051-
)
1045+
tf.hopsworks_udf.execution_mode.get_current_execution_mode(online=True)
10521046
== UDFExecutionMode.PANDAS
10531047
):
10541048
features = [
@@ -1064,14 +1058,12 @@ def apply_model_dependent_transformations(self, rows: Union[dict, pd.DataFrame])
10641058
rows[feature]
10651059
for feature in tf.hopsworks_udf.transformation_features
10661060
]
1067-
transformed_result = tf.hopsworks_udf.get_udf(inference=True)(
1061+
transformed_result = tf.hopsworks_udf.get_udf(online=True)(
10681062
*features
10691063
) # Get only python compatible UDF irrespective of engine
10701064

10711065
if (
1072-
tf.hopsworks_udf.execution_mode.get_current_execution_mode(
1073-
inference=True
1074-
)
1066+
tf.hopsworks_udf.execution_mode.get_current_execution_mode(online=True)
10751067
== UDFExecutionMode.PANDAS
10761068
):
10771069
if isinstance(transformed_result, pd.Series):

python/hsfs/engine/python.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ def _apply_transformation_function(
12631263
self,
12641264
transformation_functions: List[transformation_function.TransformationFunction],
12651265
dataset: Union[pd.DataFrame, pl.DataFrame],
1266-
inference_mode: bool = False,
1266+
online_inference: bool = False,
12671267
) -> Union[pd.DataFrame, pl.DataFrame]:
12681268
"""
12691269
Apply transformation function to the dataframe.
@@ -1304,7 +1304,7 @@ def _apply_transformation_function(
13041304

13051305
if (
13061306
hopsworks_udf.execution_mode.get_current_execution_mode(
1307-
inference=inference_mode
1307+
online=online_inference
13081308
)
13091309
== UDFExecutionMode.PANDAS
13101310
):
@@ -1334,7 +1334,7 @@ def _apply_python_udf(
13341334
# Raises
13351335
`FeatureStoreException`: If any of the features mentioned in the transformation function is not present in the Feature View.
13361336
"""
1337-
udf = hopsworks_udf.get_udf(inference=False)
1337+
udf = hopsworks_udf.get_udf(online=False)
13381338
if isinstance(dataframe, pd.DataFrame):
13391339
if len(hopsworks_udf.return_types) > 1:
13401340
dataframe[hopsworks_udf.output_column_names] = dataframe.apply(
@@ -1398,7 +1398,7 @@ def _apply_pandas_udf(
13981398
"""
13991399
if len(hopsworks_udf.return_types) > 1:
14001400
dataframe[hopsworks_udf.output_column_names] = hopsworks_udf.get_udf(
1401-
inference=False
1401+
online=False
14021402
)(
14031403
*(
14041404
[
@@ -1409,7 +1409,7 @@ def _apply_pandas_udf(
14091409
)
14101410
else:
14111411
dataframe[hopsworks_udf.output_column_names[0]] = hopsworks_udf.get_udf(
1412-
inference=False
1412+
online=False
14131413
)(
14141414
*(
14151415
[

python/hsfs/hopsworks_udf.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class UDFExecutionMode(Enum):
4242
PYTHON = "python"
4343
PANDAS = "pandas"
4444

45-
def get_current_execution_mode(self, inference):
46-
if self == UDFExecutionMode.DEFAULT and inference:
45+
def get_current_execution_mode(self, online):
46+
if self == UDFExecutionMode.DEFAULT and online:
4747
return UDFExecutionMode.PYTHON
48-
elif self == UDFExecutionMode.DEFAULT and not inference:
48+
elif self == UDFExecutionMode.DEFAULT and not online:
4949
return UDFExecutionMode.PANDAS
5050
else:
5151
return self
@@ -697,7 +697,7 @@ def update_return_type_one_hot(self):
697697
for _ in range(len(self.transformation_statistics.feature.unique_values))
698698
]
699699

700-
def get_udf(self, inference: bool = False) -> Callable:
700+
def get_udf(self, online: bool = False) -> Callable:
701701
"""
702702
Function that checks the current engine type, execution type and returns the appropriate UDF.
703703
@@ -719,10 +719,10 @@ def get_udf(self, inference: bool = False) -> Callable:
719719
"""
720720

721721
if (
722-
self.execution_mode.get_current_execution_mode(inference)
722+
self.execution_mode.get_current_execution_mode(online)
723723
== UDFExecutionMode.PANDAS
724724
):
725-
if engine.get_type() in ["python", "training"] or inference:
725+
if engine.get_type() in ["python", "training"] or online:
726726
return self.pandas_udf_wrapper()
727727
else:
728728
from pyspark.sql.functions import pandas_udf
@@ -732,10 +732,10 @@ def get_udf(self, inference: bool = False) -> Callable:
732732
returnType=self._create_pandas_udf_return_schema_from_list(),
733733
)
734734
elif (
735-
self.execution_mode.get_current_execution_mode(inference)
735+
self.execution_mode.get_current_execution_mode(online)
736736
== UDFExecutionMode.PYTHON
737737
):
738-
if engine.get_type() in ["python", "training"] or inference:
738+
if engine.get_type() in ["python", "training"] or online:
739739
# Renaming into correct column names done within Python engine since a wrapper does not work for polars dataFrames.
740740
return self.python_udf_wrapper(rename_outputs=False)
741741
else:

python/tests/test_hopswork_udf.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def test(feature):
874874
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
875875
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
876876

877-
_ = test.get_udf(inference=False)
877+
_ = test.get_udf(online=False)
878878

879879
assert pandas_udf_mocker.call_count == 1
880880
assert python_udf_mocker.call_count == 0
@@ -893,7 +893,7 @@ def test(feature):
893893
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
894894
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
895895

896-
_ = test.get_udf(inference=True)
896+
_ = test.get_udf(online=True)
897897

898898
assert pandas_udf_mocker.call_count == 0
899899
assert python_udf_mocker.call_count == 0
@@ -912,7 +912,7 @@ def test(feature):
912912
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
913913
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
914914

915-
_ = test.get_udf(inference=False)
915+
_ = test.get_udf(online=False)
916916

917917
assert pandas_udf_mocker.call_count == 0
918918
assert python_udf_mocker.call_count == 1
@@ -931,7 +931,7 @@ def test(feature):
931931
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
932932
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
933933

934-
_ = test.get_udf(inference=True)
934+
_ = test.get_udf(online=True)
935935

936936
assert pandas_udf_mocker.call_count == 0
937937
assert python_udf_mocker.call_count == 0
@@ -950,7 +950,7 @@ def test(feature):
950950
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
951951
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
952952

953-
_ = test.get_udf(inference=False)
953+
_ = test.get_udf(online=False)
954954

955955
assert pandas_udf_mocker.call_count == 1
956956
assert python_udf_mocker.call_count == 0
@@ -969,7 +969,7 @@ def test(feature):
969969
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
970970
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
971971

972-
_ = test.get_udf(inference=True)
972+
_ = test.get_udf(online=True)
973973

974974
assert pandas_udf_mocker.call_count == 0
975975
assert python_udf_mocker.call_count == 0
@@ -988,7 +988,7 @@ def test(feature):
988988
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
989989
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
990990

991-
_ = test.get_udf(inference=False)
991+
_ = test.get_udf(online=False)
992992

993993
assert pandas_udf_mocker.call_count == 0
994994
assert python_udf_mocker.call_count == 0
@@ -1007,7 +1007,7 @@ def test(feature):
10071007
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
10081008
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
10091009

1010-
_ = test.get_udf(inference=True)
1010+
_ = test.get_udf(online=True)
10111011

10121012
assert pandas_udf_mocker.call_count == 0
10131013
assert python_udf_mocker.call_count == 0
@@ -1026,7 +1026,7 @@ def test(feature):
10261026
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
10271027
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
10281028

1029-
_ = test.get_udf(inference=False)
1029+
_ = test.get_udf(online=False)
10301030

10311031
assert pandas_udf_mocker.call_count == 0
10321032
assert python_udf_mocker.call_count == 0
@@ -1045,7 +1045,7 @@ def test(feature):
10451045
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
10461046
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
10471047

1048-
_ = test.get_udf(inference=True)
1048+
_ = test.get_udf(online=True)
10491049

10501050
assert pandas_udf_mocker.call_count == 0
10511051
assert python_udf_mocker.call_count == 0
@@ -1064,7 +1064,7 @@ def test(feature):
10641064
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
10651065
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
10661066

1067-
_ = test.get_udf(inference=False)
1067+
_ = test.get_udf(online=False)
10681068

10691069
assert pandas_udf_mocker.call_count == 0
10701070
assert python_udf_mocker.call_count == 0
@@ -1083,7 +1083,7 @@ def test(feature):
10831083
pandas_wrapper_mocker = mocker.patch.object(test, "pandas_udf_wrapper")
10841084
python_wrapper_mocker = mocker.patch.object(test, "python_udf_wrapper")
10851085

1086-
_ = test.get_udf(inference=True)
1086+
_ = test.get_udf(online=True)
10871087

10881088
assert pandas_udf_mocker.call_count == 0
10891089
assert python_udf_mocker.call_count == 0

0 commit comments

Comments
 (0)