Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a dependencies method to LambdaOp #498

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nvtabular/ops/lambdaop.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ class LambdaOp(Operator):
Whether to replace existing columns or create new ones.
"""

def __init__(self, f):
def __init__(self, f, dependency=None):
super().__init__()
if f is None:
raise ValueError("f cannot be None. LambdaOp op applies f to dataframe")
self.f = f
self._param_count = len(signature(self.f).parameters)
if self._param_count not in (1, 2):
raise ValueError("lambda function must accept either one or two parameters")
self.dependency = dependency

@annotate("DFLambda_op", color="darkgreen", domain="nvt_python")
def transform(self, columns, gdf: cudf.DataFrame):
Expand All @@ -96,3 +97,6 @@ def transform(self, columns, gdf: cudf.DataFrame):
# shouldn't ever happen,
raise RuntimeError(f"unhandled lambda param count {self._param_count}")
return new_gdf

def dependencies(self):
return self.dependency