Repository: SAP/data-attribute-recommendation-python-sdk

Issue:
InferenceClient: document retry parameter

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4859204..a64742c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
-## [Unreleased]
+## [Unreleased] - To be 0.7.0
 
 ### Added
 
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 * `ModelCreator.create` performs an initial check if the model name is already used
   and raises `ModelAlreadyExists` in this case [#60], [#64]
 * `ModelManager.wait_for_job` now logs with level INFO while polling [#66]
+* Change default `retry` parameter in `InferenceClient.do_bulk_inference` from
+  `False` to `True`. Please check the updated documentation for implications on
+   charging. [#67], [#62]
 
 ### Fixed
 
@@ -27,9 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 [#58]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/58
 [#59]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/59
 [#60]: https://github.com/SAP/data-attribute-recommendation-python-sdk/issues/60
+[#62]: https://github.com/SAP/data-attribute-recommendation-python-sdk/issues/62
 [#63]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/63
 [#64]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/64
 [#66]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/66
+[#67]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/67
 [#69]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/69
 
 ## [0.6.8]
diff --git a/sap/aibus/dar/client/inference_client.py b/sap/aibus/dar/client/inference_client.py
index c98aaef..23c9c93 100644
--- a/sap/aibus/dar/client/inference_client.py
+++ b/sap/aibus/dar/client/inference_client.py
@@ -49,7 +49,7 @@ class InferenceClient(BaseClientWithSession):
         :param model_name: name of the model used for inference
         :param objects: Objects to be classified
         :param top_n: How many predictions to return per object
-        :param retry: whether to retry on errors. Default: false
+        :param retry: whether to retry on errors. Default: False
         :return: API response
         """
         self.log.debug(
@@ -72,7 +72,7 @@ class InferenceClient(BaseClientWithSession):
         model_name: str,
         objects: List[dict],
         top_n: int = TOP_N,
-        retry: bool = False,
+        retry: bool = True,
     ) -> List[dict]:
         """
         Performs bulk inference for larger collections.
@@ -83,9 +83,35 @@ class InferenceClient(BaseClientWithSession):
         Returns the aggregated values of the *predictions* of the original API response
         as returned by :meth:`create_inference_request`.
 
+        .. note::
+
+            This method calls the inference endpoint multiple times to process all data.
+            For non-trial service instances, each call will incur a cost.
+
+            If one of the calls fails, this method will raise an Exception and the
+            progress will be lost. In this case, all calls until the Exception happened
+            will be charged.
+
+            To reduce the likelihood of a failed request terminating the bulk inference
+            process, this method will retry failed requests.
+
+            There is a small chance that even retried requests will be charged, e.g.
+            if a problem occurs with the request on the client side outside of the
+            control of the service and after the service has processed the request.
+            To disable `retry` behavior simply pass `retry=False` to the method.
+
+            Typically, the default behavior of `retry=True` is safe and improves
+            reliability of bulk inference greatly.
+
+        .. versionchanged:: 0.7.0
+            The default for the `retry` parameter changed from `retry=False` to
+            `retry=True` for increased reliability in day-to-day operations.
+
+
         :param model_name: name of the model used for inference
         :param objects: Objects to be classified
         :param top_n: How many predictions to return per object
+        :param retry: whether to retry on errors. Default: True
         :return: the aggregated ObjectPrediction dictionaries
         """
         result = []  # type: List[dict]


Test patch:
diff --git a/tests/sap/aibus/dar/client/test_inference_client.py b/tests/sap/aibus/dar/client/test_inference_client.py
index 155d7f0..49e9398 100644
--- a/tests/sap/aibus/dar/client/test_inference_client.py
+++ b/tests/sap/aibus/dar/client/test_inference_client.py
@@ -183,7 +183,7 @@ class TestInferenceClient:
 
         expected_retry_flag = retry_flag
         if expected_retry_flag == "default":
-            expected_retry_flag = False
+            expected_retry_flag = True
 
         # For 75 objects, we expect two calls.
         expected_calls_to_post = [