From e761027b0e8b472b0f4d05e1fa96d3ff10dc3974 Mon Sep 17 00:00:00 2001 From: Google Earth Engine Authors Date: Tue, 14 Jan 2025 19:44:01 -0800 Subject: [PATCH] Retry on installing the cloud api resources. PiperOrigin-RevId: 715618555 --- python/ee/_cloud_api_utils.py | 4 ++++ python/ee/data.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/python/ee/_cloud_api_utils.py b/python/ee/_cloud_api_utils.py index 3eaa55570..6997d6bf4 100644 --- a/python/ee/_cloud_api_utils.py +++ b/python/ee/_cloud_api_utils.py @@ -146,6 +146,7 @@ def build_cloud_resource( api_key: Optional[str] = None, credentials: Optional[Any] = None, timeout: Optional[float] = None, + num_retries: int = 1, headers_supplier: Optional[Callable[[], Dict[str, Any]]] = None, response_inspector: Optional[Callable[[Any], None]] = None, http_transport: Optional[Any] = None, @@ -160,6 +161,8 @@ def build_cloud_resource( api_key: An API key that's enabled for use with the Earth Engine Cloud API. credentials: OAuth2 credentials to use when authenticating to the API. timeout: How long a timeout to set on requests, in seconds. + num_retries: The number of times to retry discovery with randomized + exponential backoff, in case of intermittent/connection issues. headers_supplier: A callable that will return a set of headers to be applied to a request. Will be called once for each request. response_inspector: A callable that will be invoked with the raw @@ -199,6 +202,7 @@ def build(**kwargs): requestBuilder=request_builder, model=alt_model, cache_discovery=False, + num_retries=num_retries, **kwargs) # pytype: disable=wrong-keyword-args resource = None diff --git a/python/ee/data.py b/python/ee/data.py index 620791a51..88dbfed5e 100644 --- a/python/ee/data.py +++ b/python/ee/data.py @@ -327,6 +327,7 @@ def _install_cloud_api_resource() -> None: credentials=_credentials, api_key=_cloud_api_key, timeout=timeout, + num_retries=_max_retries, headers_supplier=_make_request_headers, response_inspector=_handle_profiling_response, http_transport=_http_transport, @@ -338,6 +339,7 @@ def _install_cloud_api_resource() -> None: credentials=_credentials, api_key=_cloud_api_key, timeout=timeout, + num_retries=_max_retries, headers_supplier=_make_request_headers, response_inspector=_handle_profiling_response, http_transport=_http_transport,