From 3450731180dfca1eb12edbc97d46032c40891e05 Mon Sep 17 00:00:00 2001 From: Shobhit Singh Date: Thu, 17 Apr 2025 23:31:48 +0000 Subject: [PATCH 1/2] docs: note that `udf` is in preview and must be python 3.11 compatible --- bigframes/functions/_function_session.py | 9 ++++++--- bigframes/session/__init__.py | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bigframes/functions/_function_session.py b/bigframes/functions/_function_session.py index ec0e977782..3e5bcec591 100644 --- a/bigframes/functions/_function_session.py +++ b/bigframes/functions/_function_session.py @@ -740,9 +740,12 @@ def udf( BigQuery managed function. .. note:: - The udf must be self-contained, i.e. it must not contain any + This feature is in preview. The code in the udf must be + (1) self-contained, i.e. it must not contain any references to an import or variable defined outside the function - body. + body, and + (2) Python 3.11 compatible, as that is the environment + in which the code is executed in the cloud. .. note:: Please have following IAM roles enabled for you: @@ -801,7 +804,7 @@ def udf( https://pip.pypa.io/en/stable/reference/requirements-file-format/. """ - warnings.warn("udf is in preview.", category=bfe.PreviewWarning) + warnings.warn("udf is in preview.", category=bfe.PreviewWarning, stacklevel=6) # Some defaults may be used from the session if not provided otherwise. session = self._resolve_session(session) diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 9d45019fc5..844e1023da 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -1450,9 +1450,12 @@ def udf( BigQuery managed function. .. note:: - The udf must be self-contained, i.e. it must not contain any + This feature is in preview. The code in the udf must be + (1) self-contained, i.e. it must not contain any references to an import or variable defined outside the function - body. + body, and + (2) Python 3.11 compatible, as that is the environment + in which the code is executed in the cloud. .. note:: Please have following IAM roles enabled for you: From 49bb19441eafe056abe08a7d1e82daa0a11364c0 Mon Sep 17 00:00:00 2001 From: Shobhit Singh Date: Thu, 17 Apr 2025 23:51:30 +0000 Subject: [PATCH 2/2] user stacklevel=5 to optimize the warning for bpd.udf entry point --- bigframes/functions/_function_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigframes/functions/_function_session.py b/bigframes/functions/_function_session.py index 3e5bcec591..b75262dc30 100644 --- a/bigframes/functions/_function_session.py +++ b/bigframes/functions/_function_session.py @@ -804,7 +804,7 @@ def udf( https://pip.pypa.io/en/stable/reference/requirements-file-format/. """ - warnings.warn("udf is in preview.", category=bfe.PreviewWarning, stacklevel=6) + warnings.warn("udf is in preview.", category=bfe.PreviewWarning, stacklevel=5) # Some defaults may be used from the session if not provided otherwise. session = self._resolve_session(session)