|
47 | 47 | )
|
48 | 48 |
|
49 | 49 | from bigframes import clients
|
| 50 | +from bigframes import version as bigframes_version |
50 | 51 | import bigframes.core.compile.ibis_types
|
51 | 52 | import bigframes.exceptions as bfe
|
52 | 53 | import bigframes.series as bf_series
|
@@ -265,6 +266,13 @@ def remote_function(
|
265 | 266 | .. deprecated:: 0.0.1
|
266 | 267 | This is an internal method. Please use :func:`bigframes.pandas.remote_function` instead.
|
267 | 268 |
|
| 269 | + .. warning:: |
| 270 | + To use remote functions with Bigframes 2.0 and onwards, please (preferred) |
| 271 | + set an explicit user-managed ``cloud_function_service_account`` or (discouraged) |
| 272 | + set ``cloud_function_service_account`` to use the Compute Engine service account |
| 273 | + by setting it to `"default"`. |
| 274 | + See, https://cloud.google.com/functions/docs/securing/function-identity. |
| 275 | +
|
268 | 276 | .. note::
|
269 | 277 | Please make sure following is setup before using this API:
|
270 | 278 |
|
@@ -445,6 +453,26 @@ def remote_function(
|
445 | 453 | # Some defaults may be used from the session if not provided otherwise.
|
446 | 454 | session = self._resolve_session(session)
|
447 | 455 |
|
| 456 | + # raise a UserWarning if user does not explicitly set cloud_function_service_account to a |
| 457 | + # user-managed cloud_function_service_account of to default |
| 458 | + msg = bfe.format_message( |
| 459 | + "You have not explicitly set a user-managed `cloud_function_service_account`. " |
| 460 | + "Using the default Compute Engine service account. " |
| 461 | + "To use Bigframes 2.0, please explicitly set `cloud_function_service_account` " |
| 462 | + 'either to a user-managed service account (preferred) or to `"default"` ' |
| 463 | + "to use the Compute Engine service account (discouraged). " |
| 464 | + "See, https://cloud.google.com/functions/docs/securing/function-identity." |
| 465 | + ) |
| 466 | + |
| 467 | + if ( |
| 468 | + bigframes_version.__version__.startswith("1.") |
| 469 | + and cloud_function_service_account is None |
| 470 | + ): |
| 471 | + warnings.warn(msg, stacklevel=2, category=FutureWarning) |
| 472 | + |
| 473 | + if cloud_function_service_account == "default": |
| 474 | + cloud_function_service_account = None |
| 475 | + |
448 | 476 | # A BigQuery client is required to perform BQ operations.
|
449 | 477 | bigquery_client = self._resolve_bigquery_client(session, bigquery_client)
|
450 | 478 |
|
|
0 commit comments