3333)
3434import warnings
3535
36- import bigframes_vendored .constants as constants
3736import bigframes_vendored .ibis .backends .bigquery .datatypes as third_party_ibis_bqtypes
3837import bigframes_vendored .ibis .expr .datatypes as ibis_dtypes
3938import bigframes_vendored .ibis .expr .operations .udf as ibis_udf
4948from bigframes import clients
5049import bigframes .core .compile .ibis_types
5150import bigframes .exceptions as bfe
51+ import bigframes .formatting_helpers as bf_formatting
5252import bigframes .series as bf_series
5353
5454if TYPE_CHECKING :
@@ -87,9 +87,10 @@ def _resolve_bigquery_client(
8787 if not bigquery_client :
8888 bigquery_client = session .bqclient
8989 if not bigquery_client :
90- raise ValueError (
90+ raise bf_formatting .create_exception_with_feedback_link (
91+ ValueError ,
9192 "A bigquery client must be provided, either directly or via "
92- f "session. { constants . FEEDBACK_LINK } "
93+ "session." ,
9394 )
9495 return bigquery_client
9596
@@ -104,9 +105,10 @@ def _resolve_bigquery_connection_client(
104105 if not bigquery_connection_client :
105106 bigquery_connection_client = session .bqconnectionclient
106107 if not bigquery_connection_client :
107- raise ValueError (
108+ raise bf_formatting .create_exception_with_feedback_link (
109+ ValueError ,
108110 "A bigquery connection client must be provided, either "
109- f "directly or via session. { constants . FEEDBACK_LINK } "
111+ "directly or via session." ,
110112 )
111113 return bigquery_connection_client
112114
@@ -119,9 +121,10 @@ def _resolve_resource_manager_client(
119121 if not resource_manager_client :
120122 resource_manager_client = session .resourcemanagerclient
121123 if not resource_manager_client :
122- raise ValueError (
124+ raise bf_formatting .create_exception_with_feedback_link (
125+ ValueError ,
123126 "A resource manager client must be provided, either directly "
124- f "or via session. { constants . FEEDBACK_LINK } "
127+ "or via session." ,
125128 )
126129 return resource_manager_client
127130
@@ -149,9 +152,10 @@ def _resolve_cloud_functions_client(
149152 if not cloud_functions_client :
150153 cloud_functions_client = session .cloudfunctionsclient
151154 if not cloud_functions_client :
152- raise ValueError (
155+ raise bf_formatting .create_exception_with_feedback_link (
156+ ValueError ,
153157 "A cloud functions client must be provided, either directly "
154- f "or via session. { constants . FEEDBACK_LINK } "
158+ "or via session." ,
155159 )
156160 return cloud_functions_client
157161
@@ -178,14 +182,16 @@ def _resolve_bigquery_connection_id(
178182 bq_connection_id ,
179183 ) = bigquery_connection .split ("." )
180184 if gcp_project_id .casefold () != dataset_ref .project .casefold ():
181- raise ValueError (
185+ raise bf_formatting .create_exception_with_feedback_link (
186+ ValueError ,
182187 "The project_id does not match BigQuery connection "
183- f"gcp_project_id: { dataset_ref .project } ."
188+ f"gcp_project_id: { dataset_ref .project } ." ,
184189 )
185190 if bq_connection_location .casefold () != bq_location .casefold ():
186- raise ValueError (
191+ raise bf_formatting .create_exception_with_feedback_link (
192+ ValueError ,
187193 "The location does not match BigQuery connection location: "
188- f"{ bq_location } ."
194+ f"{ bq_location } ." ,
189195 )
190196 return bq_connection_id
191197
@@ -506,9 +512,10 @@ def remote_function(
506512 cloud_function_kms_key_name is not None
507513 and cloud_function_docker_repository is None
508514 ):
509- raise ValueError (
515+ raise bf_formatting .create_exception_with_feedback_link (
516+ ValueError ,
510517 "cloud_function_docker_repository must be specified with cloud_function_kms_key_name."
511- " For more details see https://cloud.google.com/functions/docs/securing/cmek#before_you_begin"
518+ " For more details see https://cloud.google.com/functions/docs/securing/cmek#before_you_begin." ,
512519 )
513520
514521 if cloud_function_ingress_settings is None :
@@ -521,13 +528,25 @@ def remote_function(
521528 )
522529 warnings .warn (msg , category = FutureWarning , stacklevel = 2 )
523530
531+ if cloud_function_ingress_settings is None :
532+ cloud_function_ingress_settings = "all"
533+ msg = bfe .format_message (
534+ "The `cloud_function_ingress_settings` are set to 'all' by default, "
535+ "which will change to 'internal-only' for enhanced security in future version 2.0 onwards. "
536+ "However, you will be able to explicitly pass cloud_function_ingress_settings='all' if you need. "
537+ "See https://cloud.google.com/functions/docs/networking/network-settings#ingress_settings for details."
538+ )
539+ warnings .warn (msg , category = FutureWarning , stacklevel = 2 )
540+
524541 bq_connection_manager = session .bqconnectionmanager
525542
526543 def wrapper (func ):
527544 nonlocal input_types , output_type
528545
529546 if not callable (func ):
530- raise TypeError ("f must be callable, got {}" .format (func ))
547+ raise bf_formatting .create_exception_with_feedback_link (
548+ TypeError , f"func must be a callable, got { func } "
549+ )
531550
532551 if sys .version_info >= (3 , 10 ):
533552 # Add `eval_str = True` so that deferred annotations are turned into their
@@ -547,10 +566,11 @@ def wrapper(func):
547566 input_types = []
548567 for parameter in signature .parameters .values ():
549568 if (param_type := parameter .annotation ) is inspect .Signature .empty :
550- raise ValueError (
569+ raise bf_formatting .create_exception_with_feedback_link (
570+ ValueError ,
551571 "'input_types' was not set and parameter "
552572 f"'{ parameter .name } ' is missing a type annotation. "
553- "Types are required to use @remote_function."
573+ "Types are required to use @remote_function." ,
554574 )
555575 input_types .append (param_type )
556576 elif not isinstance (input_types , collections .abc .Sequence ):
@@ -560,10 +580,11 @@ def wrapper(func):
560580 if (
561581 output_type := signature .return_annotation
562582 ) is inspect .Signature .empty :
563- raise ValueError (
583+ raise bf_formatting .create_exception_with_feedback_link (
584+ ValueError ,
564585 "'output_type' was not set and function is missing a "
565586 "return type annotation. Types are required to use "
566- "@remote_function."
587+ "@remote_function." ,
567588 )
568589
569590 # The function will actually be receiving a pandas Series, but allow both
@@ -789,14 +810,15 @@ def udf(
789810 https://pip.pypa.io/en/stable/reference/requirements-file-format/.
790811 """
791812 if not bigframes .options .experiments .udf :
792- raise NotImplementedError ( )
813+ raise bf_formatting . create_exception_with_feedback_link ( NotImplementedError )
793814
794815 # Check the Python version.
795816 python_version = _utils .get_python_version ()
796817 if python_version not in _MANAGED_FUNC_PYTHON_VERSIONS :
797- raise RuntimeError (
818+ raise bf_formatting .create_exception_with_feedback_link (
819+ RuntimeError ,
798820 f"Python version { python_version } is not supported yet for "
799- "BigFrames managed function."
821+ "BigFrames managed function." ,
800822 )
801823
802824 # Some defaults may be used from the session if not provided otherwise.
@@ -823,7 +845,9 @@ def wrapper(func):
823845 nonlocal input_types , output_type
824846
825847 if not callable (func ):
826- raise TypeError ("f must be callable, got {}" .format (func ))
848+ raise bf_formatting .create_exception_with_feedback_link (
849+ TypeError , f"func must be a callable, got { func } "
850+ )
827851
828852 # Managed function supports version >= 3.11.
829853 signature_kwargs : Mapping [str , Any ] = {"eval_str" : True }
@@ -834,10 +858,11 @@ def wrapper(func):
834858 input_types = []
835859 for parameter in signature .parameters .values ():
836860 if (param_type := parameter .annotation ) is inspect .Signature .empty :
837- raise ValueError (
861+ raise bf_formatting .create_exception_with_feedback_link (
862+ ValueError ,
838863 "'input_types' was not set and parameter "
839864 f"'{ parameter .name } ' is missing a type annotation. "
840- "Types are required to use managed function."
865+ "Types are required to use managed function." ,
841866 )
842867 input_types .append (param_type )
843868 elif not isinstance (input_types , collections .abc .Sequence ):
@@ -847,10 +872,11 @@ def wrapper(func):
847872 if (
848873 output_type := signature .return_annotation
849874 ) is inspect .Signature .empty :
850- raise ValueError (
875+ raise bf_formatting .create_exception_with_feedback_link (
876+ ValueError ,
851877 "'output_type' was not set and function is missing a "
852878 "return type annotation. Types are required to use "
853- "managed function."
879+ "managed function." ,
854880 )
855881
856882 # The function will actually be receiving a pandas Series, but allow
0 commit comments