Skip to content

Commit

Permalink
Apply formatter.
Browse files Browse the repository at this point in the history
  • Loading branch information
shunping committed Jun 10, 2024
1 parent 6260d57 commit 82dcb13
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
7 changes: 4 additions & 3 deletions sdks/python/apache_beam/io/gcp/gcsio.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,15 @@ def is_soft_delete_enabled(self, gcs_path):
bucket_name, _ = parse_gcs_path(gcs_path)
bucket = self.get_bucket(bucket_name)
if (bucket.soft_delete_policy is not None and
bucket.soft_delete_policy.retention_duration_seconds > 0):
bucket.soft_delete_policy.retention_duration_seconds > 0):
return True
except Exception:
_LOGGER.warning(
"Unexpected error occurred when checking soft delete policy for %s"
% gcs_path)
"Unexpected error occurred when checking soft delete policy for %s" %
gcs_path)
return False


class BeamBlobReader(BlobReader):
def __init__(self, blob, chunk_size=DEFAULT_READ_BUFFER_SIZE):
super().__init__(blob, chunk_size=chunk_size)
Expand Down
8 changes: 4 additions & 4 deletions sdks/python/apache_beam/io/gcp/gcsio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,13 @@ def test_is_soft_delete_enabled(self, mock_get_bucket):

# soft delete policy enabled
bucket.soft_delete_policy.retention_duration_seconds = 1024
self.assertTrue(self.gcs.is_soft_delete_enabled(
"gs://beam_with_soft_delete/tmp"))
self.assertTrue(
self.gcs.is_soft_delete_enabled("gs://beam_with_soft_delete/tmp"))

# soft delete policy disabled
bucket.soft_delete_policy.retention_duration_seconds = 0
self.assertFalse(self.gcs.is_soft_delete_enabled(
"gs://beam_without_soft_delete/tmp"))
self.assertFalse(
self.gcs.is_soft_delete_enabled("gs://beam_without_soft_delete/tmp"))


if __name__ == '__main__':
Expand Down
19 changes: 9 additions & 10 deletions sdks/python/apache_beam/options/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,17 +922,16 @@ def _warn_if_soft_delete_policy_enabled(self, arg_name):
try:
from apache_beam.io.gcp import gcsio
if gcsio.GcsIO.is_soft_delete_enabled(gcs_path):
_LOGGER.warning(
"Bucket specified in %s has soft-delete policy enabled."
" To avoid being billed for unnecessary storage costs, turn"
" off the soft delete feature on buckets that your Dataflow"
" jobs use for temporary and staging storage. For more"
" information, see"
" https://cloud.google.com/storage/docs/use-soft-delete"
"#remove-soft-delete-policy." % arg_name)
_LOGGER.warning(
"Bucket specified in %s has soft-delete policy enabled."
" To avoid being billed for unnecessary storage costs, turn"
" off the soft delete feature on buckets that your Dataflow"
" jobs use for temporary and staging storage. For more"
" information, see"
" https://cloud.google.com/storage/docs/use-soft-delete"
"#remove-soft-delete-policy." % arg_name)
except ImportError:
_LOGGER.warning(
'Unable to check soft delete policy due to import error.')
_LOGGER.warning('Unable to check soft delete policy due to import error.')

# If either temp or staging location has an issue, we use the valid one for
# both locations. If both are bad we return an error.
Expand Down

0 comments on commit 82dcb13

Please sign in to comment.