8000 Fix: Remove deprecated num_retries argument (#1377) · googleapis/python-storage@eadf9ae · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eadf9ae

Browse files
authored
Fix: Remove deprecated num_retries argument (#1377)
1 parent ae917ee commit eadf9ae

File tree

6 files changed

+14
-447
lines changed

6 files changed

+14
-447
lines changed

google/cloud/storage/_helpers.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@
7272
("if_source_metageneration_not_match", "ifSourceMetagenerationNotMatch"),
7373
)
7474

75-
_NUM_RETRIES_MESSAGE = (
76-
"`num_retries` has been deprecated and will be removed in a future "
77-
"release. Use the `retry` argument with a Retry or ConditionalRetryPolicy "
78-
"object, or None, instead."
79-
)
80-
8175
# _NOW() returns the current local date and time.
8276
# It is preferred to use timezone-aware datetimes _NOW(_UTC),
8377
# which returns the current UTC date and time.
@@ -631,36 +625,25 @@ def _bucket_bound_hostname_url(host, scheme=None):
631625
return f"{scheme}://{host}"
632626

633627

634-
def _api_core_retry_to_resumable_media_retry(retry, num_retries=None):
628+
def _api_core_retry_to_resumable_media_retry(retry):
635629
"""Convert google.api.core.Retry to google.cloud.storage._media.RetryStrategy.
636630
637631
Custom predicates are not translated.
638632
639633
:type retry: google.api_core.Retry
640634
:param retry: (Optional) The google.api_core.Retry object to translate.
641635
642-
:type num_retries: int
643-
:param num_retries: (Optional) The number of retries desired. This is
644-
supported for backwards compatibility and is mutually exclusive with
645-
`retry`.
646-
647636
:rtype: google.cloud.storage._media.RetryStrategy
648-
:returns: A RetryStrategy with all applicable attributes copied from input,
649-
or a RetryStrategy with max_retries set to 0 if None was input.
637+
:returns: A RetryStrategy with all applicable attributes copied from input.
650638
"""
651639

652-
if retry is not None and num_retries is not None:
653-
raise ValueError("num_retries and retry arguments are mutually exclusive")
654-
655-
elif retry is not None:
640+
if retry is not None:
656641
return _media.RetryStrategy(
657642
max_sleep=retry._maximum,
658643
max_cumulative_retry=retry._deadline,
659644
initial_delay=retry._initial,
660645
multiplier=retry._multiplier,
661646
)
662-
elif num_retries is not None:
663-
return _media.RetryStrategy(max_retries=num_retries)
664647
else:
665648
return _media.RetryStrategy(max_retries=0)
666649

google/cloud/storage/blob.py

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
from google.cloud.storage._helpers import _get_default_storage_base_url
6060
from google.cloud.storage._signing import generate_signed_url_v2
6161
from google.cloud.storage._signing import generate_signed_url_v4
62-
from google.cloud.storage._helpers import _NUM_RETRIES_MESSAGE
6362
from google.cloud.storage._helpers import _API_VERSION
6463
from google.cloud.storage._helpers import _virtual_hosted_style_base_url
6564
from google.cloud.storage.acl import ACL
@@ -1829,7 +1828,6 @@ def _do_multipart_upload(
18291828
stream,
18301829
content_type,
18311830
size,
1832-
num_retries,
18331831
predefined_acl,
18341832
if_generation_match,
18351833
if_generation_not_match,
@@ -1866,15 +1864,6 @@ def _do_multipart_upload(
18661864
``stream``). If not provided, the upload will be concluded once
18671865
``stream`` is exhausted (or :data:`None`).
18681866
1869-
:type num_retries: int
1870-
:param num_retries:
1871-
Number of upload retries. By default, only uploads with
1872-
if_generation_match set will be retried, as uploads without the
1873-
argument are not guaranteed to be idempotent. Setting num_retries
1874-
will override this default behavior and guarantee retries even when
1875-
if_generation_match is not set. (Deprecated: This argument
1876-
will be removed in a future release.)
1877-
18781867
:type predefined_acl: str
18791868
:param predefined_acl: (Optional) Predefined access control list
18801869
@@ -1989,9 +1978,7 @@ def _do_multipart_upload(
19891978
upload_url = _add_query_parameters(base_url, name_value_pairs)
19901979
upload = MultipartUpload(upload_url, headers=headers, checksum=checksum)
19911980

1992-
upload._retry_strategy = _api_core_retry_to_resumable_media_retry(
1993-
retry, num_retries
1994-
)
1981+
upload._retry_strategy = _api_core_retry_to_resumable_media_retry(retry)
19951982

19961983
response = upload.transmit(
19971984
transport, data, object_metadata, content_type, timeout=timeout
@@ -2005,7 +1992,6 @@ def _initiate_resumable_upload(
20051992
stream,
20061993
content_type,
20071994
size,
2008-
num_retries,
20091995
predefined_acl=None,
20101996
extra_headers=None,
20111997
chunk_size=None,
@@ -2047,15 +2033,6 @@ def _initiate_resumable_upload(
20472033
:type predefined_acl: str
20482034
:param predefined_acl: (Optional) Predefined access control list
20492035
2050-
:type num_retries: int
2051-
:param num_retries:
2052-
Number of upload retries. By default, only uploads with
2053-
if_generation_match set will be retried, as uploads without the
2054-
argument are not guaranteed to be idempotent. Setting num_retries
2055-
will override this default behavior and guarantee retries even when
2056-
if_generation_match is not set. (Deprecated: This argument
2057-
will be removed in a future release.)
2058-
20592036
:type extra_headers: dict
20602037
:param extra_headers:
20612038
(Optional) Extra headers to add to standard headers.
@@ -2185,9 +2162,7 @@ def _initiate_resumable_upload(
21852162
upload_url, chunk_size, headers=headers, checksum=checksum
21862163
)
21872164

2188-
upload._retry_strategy = _api_core_retry_to_resumable_media_retry(
2189-
retry, num_retries
2190-
)
2165+
upload._retry_strategy = _api_core_retry_to_resumable_media_retry(retry)
21912166

21922167
upload.initiate(
21932168
transport,
@@ -2207,7 +2182,6 @@ def _do_resumable_upload(
22072182
stream,
22082183
content_type,
22092184
size,
2210-
num_retries,
22112185
predefined_acl,
22122186
if_generation_match,
22132187
if_generation_not_match,
@@ -2247,15 +2221,6 @@ def _do_resumable_upload(
22472221
``stream``). If not provided, the upload will be concluded once
22482222
``stream`` is exhausted (or :data:`None`).
22492223
2250-
:type num_retries: int
2251-
:param num_retries:
2252-
Number of upload retries. By default, only uploads with
2253-
if_generation_match set will be retried, as uploads without the
2254-
argument are not guaranteed to be idempotent. Setting num_retries
2255-
will override this default behavior and guarantee retries even when
2256-
if_generation_match is not set. (Deprecated: This argument
2257-
will be removed in a future release.)
2258-
22592224
:type predefined_acl: str
22602225
:param predefined_acl: (Optional) Predefined access control list
22612226
@@ -2320,7 +2285,6 @@ def _do_resumable_upload(
23202285
stream,
23212286
content_type,
23222287
size,
2323-
num_retries,
23242288
predefined_acl=predefined_acl,
23252289
if_generation_match=if_generation_match,
23262290
if_generation_not_match=if_generation_not_match,
@@ -2346,7 +2310,6 @@ def _do_upload(
23462310
stream,
23472311
content_type,
23482312
size,
2349-
num_retries,
23502313
predefined_acl,
23512314
if_generation_match,
23522315
if_generation_not_match,
@@ -2387,15 +2350,6 @@ def _do_upload(
23872350
``stream``). If not provided, the upload will be concluded once
23882351
``stream`` is exhausted (or :data:`None`).
23892352
2390-
:type num_retries: int
2391-
:param num_retries:
2392-
Number of upload retries. By default, only uploads with
2393-
if_generation_match set will be retried, as uploads without the
2394-
argument are not guaranteed to be idempotent. Setting num_retries
2395-
will override this default behavior and guarantee retries even when
2396-
if_generation_match is not set. (Deprecated: This argument
2397-
will be removed in a future release.)
2398-
23992353
:type predefined_acl: str
24002354
:param predefined_acl: (Optional) Predefined access control list
24012355
@@ -2485,7 +2439,6 @@ def _do_upload(
24852439
stream,
24862440
content_type,
24872441
size,
2488-
num_retries,
24892442
predefined_acl,
24902443
if_generation_match,
24912444
if_generation_not_match,
@@ -2502,7 +2455,6 @@ def _do_upload(
25022455
stream,
25032456
content_type,
25042457
size,
2505-
num_retries,
25062458
predefined_acl,
25072459
if_generation_match,
25082460
if_generation_not_match,
@@ -2522,7 +2474,6 @@ def _prep_and_do_upload(
25222474
rewind=False,
25232475
size=None,
25242476
content_type=None,
2525-
num_retries=None,
25262477
client=None,
25272478
predefined_acl=None,
25282479
if_generation_match=None,
@@ -2580,15 +2531,6 @@ def _prep_and_do_upload(
25802531
:type content_type: str
25812532
:param content_type: (Optional) Type of content being uploaded.
25822533
2583-
:type num_retries: int
2584-
:param num_retries:
2585-
Number of upload retries. By default, only uploads with
2586-
if_generation_match set will be retried, as uploads without the
2587-
argument are not guaranteed to be idempotent. Setting num_retries
2588-
will override this default behavior and guarantee retries even when
2589-
if_generation_match is not set. (Deprecated: This argument
2590-
will be removed in a future release.)
2591-
25922534
:type client: :class:`~google.cloud.storage.client.Client`
25932535
:param client:
25942536
(Optional) The client to use. If not passed, falls back to the
@@ -2662,14 +2604,6 @@ def _prep_and_do_upload(
26622604
:raises: :class:`~google.cloud.exceptions.GoogleCloudError`
26632605
if the upload response returns an error status.
26642606
"""
2665-
if num_retries is not None:
2666-
warnings.warn(_NUM_RETRIES_MESSAGE, DeprecationWarning, stacklevel=2)
2667-
# num_retries and retry are mutually exclusive. If num_retries is
2668-
# set and retry is exactly the default, then nullify retry for
2669-
# backwards compatibility.
2670-
if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED:
2671-
retry = None
2672-
26732607
_maybe_rewind(file_obj, rewind=rewind)
26742608
predefined_acl = ACL.validate_predefined(predefined_acl)
26752609

@@ -2679,7 +2613,6 @@ def _prep_and_do_upload(
26792613
file_obj,
26802614
content_type,
26812615
size,
2682-
num_retries,
26832616
predefined_acl,
26842617
if_generation_match,
26852618
if_generation_not_match,
@@ -2700,7 +2633,6 @@ def upload_from_file(
27002633
rewind=False,
27012634
size=None,
27022635
content_type=None,
2703-
num_retries=None,
27042636
client=None,
27052637
predefined_acl=None,
27062638
if_generation_match=None,
@@ -2757,15 +2689,6 @@ def upload_from_file(
27572689
:type content_type: str
27582690
:param content_type: (Optional) Type of content being uploaded.
27592691
2760-
:type num_retries: int
2761-
:param num_retries:
2762-
Number of upload retries. By default, only uploads with
2763-
if_generation_match set will be retried, as uploads without the
2764-
argument are not guaranteed to be idempotent. Setting num_retries
2765-
will override this default behavior and guarantee retries even when
2766-
if_generation_match is not set. (Deprecated: This argument
2767-
will be removed in a future release.)
2768-
27692692
:type client: :class:`~google.cloud.storage.client.Client`
27702693
:param client:
27712694
(Optional) The client to use. If not passed, falls back to the
@@ -2829,7 +2752,6 @@ def upload_from_file(
28292752
rewind=rewind,
28302753
size=size,
28312754
content_type=content_type,
2832-
num_retries=num_retries,
28332755
client=client,
28342756
predefined_acl=predefined_acl,
28352757
if_generation_match=if_generation_match,
@@ -2869,7 +2791,6 @@ def upload_from_filename(
28692791
self,
28702792
filename,
28712793
content_type=None,
2872-
num_retries=None,
28732794
client=None,
28742795
predefined_acl=None,
28752796
if_generation_match=None,
@@ -2918,15 +2839,6 @@ def upload_from_filename(
29182839
(Optional) The client to use. If not passed, falls back to the
29192840
``client`` stored on the blob's bucket.
29202841
2921-
:type num_retries: int
2922-
:param num_retries:
2923-
Number of upload retries. By default, only uploads with
2924-
if_generation_match set will be retried, as uploads without the
2925-
argument are not guaranteed to be idempotent. Setting num_retries
2926-
will override this default behavior and guarantee retries even when
2927-
if_generation_match is not set. (Deprecated: This argument
2928-
will be removed in a future release.)
2929-
29302842
:type predefined_acl: str
29312843
:param predefined_acl: (Optional) Predefined access control list
29322844
@@ -2981,7 +2893,6 @@ def upload_from_filename(
29812893
self._handle_filename_and_upload(
29822894
filename,
29832895
content_type=content_type,
2984-
num_retries=num_retries,
29852896
client=client,
29862897
predefined_acl=predefined_acl,
29872898
if_generation_match=if_generation_match,
@@ -2997,7 +2908,6 @@ def upload_from_string(
29972908
self,
29982909
data,
29992910
content_type="text/plain",
3000-
num_retries=None,
30012911
client=None,
30022912
predefined_acl=None,
30032913
if_generation_match=None,
@@ -3033,15 +2943,6 @@ def upload_from_string(
30332943
(Optional) Type of content being uploaded. Defaults to
30342944
``'text/plain'``.
30352945
3036-
:type num_retries: int
3037-
:param num_retries:
3038-
Number of upload retries. By default, only uploads with
3039-
if_generation_match set will be retried, as uploads without the
3040-
argument are not guaranteed to be idempotent. Setting num_retries
3041-
will override this default behavior and guarantee retries even when
3042-
if_generation_match is not set. (Deprecated: This argument
3043-
will be removed in a future release.)
3044-
30452946
:type client: :class:`~google.cloud.storage.client.Client`
30462947
:param client:
30472948
(Optional) The client to use. If not passed, falls back to the
@@ -3103,7 +3004,6 @@ def upload_from_string(
31033004
file_obj=string_buffer,
31043005
size=len(data),
31053006
content_type=content_type,
3106-
num_retries=num_retries,
31073007
client=client,
31083008
predefined_acl=predefined_acl,
31093009
if_generation_match=if_generation_match,
@@ -3271,7 +3171,6 @@ def create_resumable_upload_session(
32713171
fake_stream,
32723172
content_type,
32733173
size,
3274-
None,
32753174
predefined_acl=predefined_acl,
32763175
if_generation_match=if_generation_match,
32773176
if_generation_not_match=if_generation_not_match,
@@ -4061,16 +3960,9 @@ def open(
40613960
For uploads only, the following additional arguments are supported:
40623961
40633962
- ``content_type``
4064-
- ``num_retries``
40653963
- ``predefined_acl``
40663964
- ``checksum``
40673965
4068-
.. note::
4069-
4070-
``num_retries`` is supported for backwards-compatibility
4071-
reasons only; please use ``retry`` with a Retry object or
4072-
ConditionalRetryPolicy instead.
4073-
40743966
:type mode: str
40753967
:param mode:
40763968
(Optional) A mode string, as per standard Python `open()` semantics.The first

0 commit comments

Comments
 (0)
0