3737from apache_beam .options .value_provider import StaticValueProvider
3838from apache_beam .options .value_provider import ValueProvider
3939from apache_beam .transforms .display import HasDisplayData
40+ from apache_beam .utils import logs
4041from apache_beam .utils import proto_utils
4142
4243__all__ = [
@@ -422,9 +423,10 @@ def get_all_options(
422423 known_args , unknown_args = parser .parse_known_args (self ._flags )
423424 if retain_unknown_options :
424425 if unknown_args :
425- _LOGGER .warning (
426- 'Unknown pipeline options received: %s. Ignore if flags are '
427- 'used for internal purposes.' % (',' .join (unknown_args )))
426+ if logs .allow_log_once ():
427+ _LOGGER .warning (
428+ 'Unknown pipeline options received: %s. Ignore if flags are '
429+ 'used for internal purposes.' % (',' .join (unknown_args )))
428430
429431 seen = set ()
430432
@@ -466,7 +468,8 @@ def add_new_arg(arg, **kwargs):
466468 parsed_args , _ = parser .parse_known_args (self ._flags )
467469 else :
468470 if unknown_args :
469- _LOGGER .warning ("Discarding unparseable args: %s" , unknown_args )
471+ if logs .allow_log_once ():
472+ _LOGGER .warning ("Discarding unparseable args: %s" , unknown_args )
470473 parsed_args = known_args
471474 result = vars (parsed_args )
472475
@@ -1051,7 +1054,7 @@ def _create_default_gcs_bucket(self):
10511054 return None
10521055 bucket = gcsio .get_or_create_default_gcs_bucket (self )
10531056 if bucket :
1054- return 'gs://%s' % bucket .id
1057+ return 'gs://%s/ ' % bucket .id
10551058 else :
10561059 return None
10571060
@@ -1064,17 +1067,21 @@ def _warn_if_soft_delete_policy_enabled(self, arg_name):
10641067 return
10651068
10661069 gcs_path = getattr (self , arg_name , None )
1070+ if not gcs_path or not gcs_path .startswith ("gs://" ):
1071+ return
10671072 try :
10681073 from apache_beam .io .gcp import gcsio
10691074 if gcsio .GcsIO ().is_soft_delete_enabled (gcs_path ):
1070- _LOGGER .warning (
1071- "Bucket specified in %s has soft-delete policy enabled."
1072- " To avoid being billed for unnecessary storage costs, turn"
1073- " off the soft delete feature on buckets that your Dataflow"
1074- " jobs use for temporary and staging storage. For more"
1075- " information, see"
1076- " https://cloud.google.com/storage/docs/use-soft-delete"
1077- "#remove-soft-delete-policy." % arg_name )
1075+ # Use bucket name in message_id to still emit logs for different buckets
1076+ if logs .allow_log_once ("soft-delete warning" + str (gcs_path )):
1077+ _LOGGER .warning (
1078+ "Bucket specified in %s has soft-delete policy enabled."
1079+ " To avoid being billed for unnecessary storage costs, turn"
1080+ " off the soft delete feature on buckets that your Dataflow"
1081+ " jobs use for temporary and staging storage. For more"
1082+ " information, see"
1083+ " https://cloud.google.com/storage/docs/use-soft-delete"
1084+ "#remove-soft-delete-policy." % arg_name )
10781085 except ImportError :
10791086 _LOGGER .warning ('Unable to check soft delete policy due to import error.' )
10801087
0 commit comments