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

Fix inspect issue of pandas udf in SP by using kwargs #274

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/snowflake/snowpark/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@ def add_df_one(df: pd.DataFrame) -> pd.Series:
replace=replace,
parallel=parallel,
max_batch_size=max_batch_size,
_from_pandas_udf_function=True,
)
else:
return session.udf.register(
Expand All @@ -2162,6 +2163,7 @@ def add_df_one(df: pd.DataFrame) -> pd.Series:
replace=replace,
parallel=parallel,
max_batch_size=max_batch_size,
_from_pandas_udf_function=True,
)


Expand Down
9 changes: 1 addition & 8 deletions src/snowflake/snowpark/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
#
"""User-defined functions (UDFs) in Snowpark."""
import inspect
from types import ModuleType
from typing import Callable, Iterable, List, Optional, Tuple, Union

Expand Down Expand Up @@ -429,12 +428,6 @@ def register(
TempObjectType.FUNCTION, name, is_permanent, stage_location, parallel
)

# whether called from pandas_udf
caller_frame = inspect.getouterframes(inspect.currentframe())
from_pandas_udf_function = (
len(caller_frame) > 1 and caller_frame[1].function == "_pandas_udf"
)

# register udf
return self.__do_register_udf(
func,
Expand All @@ -447,7 +440,7 @@ def register(
replace,
parallel,
kwargs.get("max_batch_size"),
from_pandas_udf_function,
kwargs.get("_from_pandas_udf_function", False),
)

def register_from_file(
Expand Down