Skip to content

Commit 5959c2d

Browse files
author
Nissan Pow
committed
Restore pydash in ux test flow to verify conda env package installation
pydash is intentionally used to prove the conda environment properly resolves and installs packages, not just that code packaging works. Add pydash to both @conda steps (start and test_functions) since test_functions calls the functions that import pydash at runtime.
1 parent 2909f38 commit 5959c2d

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

tests/functions/ux/flows/function_module.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
def avro_transform_string(
99
data: str, params: Optional[FunctionParameters] = None
1010
) -> str:
11-
"""Simple avro function that transforms a string"""
11+
"""Simple avro function that transforms a string using pydash"""
12+
import pydash as _
13+
1214
suffix = params.suffix if params and hasattr(params, "suffix") else "default"
13-
return data.upper() + "_" + str(suffix)
15+
# Use pydash to uppercase the string
16+
return _.upper_case(data).replace(" ", "") + "_" + str(suffix)
1417

1518

1619
@avro_function
@@ -33,6 +36,10 @@ def json_transform_list(
3336
def json_process_object(
3437
data: dict, params: Optional[FunctionParameters] = None
3538
) -> dict:
36-
"""JSON function that adds fields to a dict"""
39+
"""JSON function that adds a field using pydash"""
40+
import pydash as _
41+
42+
# Use pydash to merge the data with new fields
3743
increment = params.increment if params and hasattr(params, "increment") else 1
38-
return {**data, "processed": True, "increment": increment}
44+
result = _.merge({}, data, {"processed": True, "increment": increment})
45+
return result

tests/functions/ux/flows/hellosimplefunction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class HelloSimpleFunction(FlowSpec):
5-
@conda
5+
@conda(libraries={"pydash": "5.1.0"})
66
@step
77
def start(self):
88
# Set parameters - these will be used by the functions
@@ -30,7 +30,7 @@ def bind_functions(self):
3030

3131
self.next(self.test_functions)
3232

33-
@conda
33+
@conda(libraries={"pydash": "5.1.0"})
3434
@step
3535
def test_functions(self):
3636
from metaflow_extensions.nflx.plugins.functions.core.function import (

0 commit comments

Comments
 (0)