automl_utils Module
General purpose utils for AutoML wide code
Functions
get_automl_resource_url
This function returns the resource url where models are hosted in the current region
get_automl_resource_url()
retry_with_backoff
Function decorator that attempts to retry the wrapped function a fixed number of times, with exponential backoff.
Usage:
@retry_with_backoff(retries=3, delay=5, backoff=2, logger=None)
def service_request():
# function logic that may raise an exception, but may
# return a successful response subsequently
The above example will retry the function service_request() 3 times, at intervals of 5 sec, 10 sec, 20 sec
Currently a retry will be done for any exception thrown. However, as per need, this can be easily extended to handle only a specific set of exceptions and pass/raise the others.
Note: Make sure the exceptions don't contain PII, or in other words, you're in control of the logger.
Reference: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
retry_with_backoff(retries: int, delay: int = 5, backoff: int = 2, raise_ex: bool = True) -> Callable[[...], Callable[[...], Any]]
Parameters
Name | Description |
---|---|
retries
Required
|
The number of retries to attempt |
delay
|
A fixed delay in seconds to begin with Default value: 5
|
backoff
|
Multiplying factor by which to delay the subsequent retries Default value: 2
|
raise_ex
|
Whether to raise exception if all retries are exhausted Default value: True
|
logger
Required
|
Optional logger to help log exception details |
Returns
Type | Description |
---|---|
Any (whatever the wrapped function returns) |