python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

WIP: Retry with a custom function

Open elena-kolevska opened this issue 1 year ago • 2 comments

NOTE: The lint tests are currently failing because of a change introduced in Ruff 0.3 which is incompatible with our flake8 set-up. We should solve this issue in a separate PR.

Description

This PR adds the possibility for users to configure Retry and Timeout policies for both grpc and http based clients.

Issue reference

https://github.com/dapr/python-sdk/issues/676

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • [X] Code compiles correctly
  • [X] Created/updated tests
  • [ ] Extended the documentation

elena-kolevska avatar Feb 27 '24 11:02 elena-kolevska

Codecov Report

Attention: Patch coverage is 88.07947% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 86.34%. Comparing base (fc0e9d1) to head (f98f36c). Report is 21 commits behind head on main.

Files Patch % Lines
dapr/clients/retry.py 82.71% 14 Missing :warning:
dapr/conf/__init__.py 50.00% 2 Missing :warning:
dapr/actor/client/proxy.py 50.00% 1 Missing :warning:
dapr/aio/clients/grpc/client.py 90.90% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
- Coverage   86.37%   86.34%   -0.03%     
==========================================
  Files          79       84       +5     
  Lines        4094     4306     +212     
==========================================
+ Hits         3536     3718     +182     
- Misses        558      588      +30     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 28 '24 23:02 codecov[bot]

The lint tests are currently failing because of a change introduced in Ruff 0.3 which is incompatible with our flake8 set-up. We should solve this issue in a separate PR.

elena-kolevska avatar Mar 03 '24 03:03 elena-kolevska

Is this PR ready @elena-kolevska ?

I kept the ruff version at 0.2.2 for now. Lint and Ruff are passing with that.

berndverst avatar May 01 '24 00:05 berndverst

It's almost ready, I just wanted to confirm a few things with you:

  • Right now the code will retry if the env variable is set, with no additional code changes. I also made it possible for users to tune other retry-related parameters (like initial_backoff, max_backoff, retryable_http_status_codes for ex.). Do you think the need ffor it justifies the added code complexity, and heavier constructors?
  • For now, I only added the retry wrapper to one method, the save_state one. Once we confirm this is the right approach, I'll update all methods in the class.
  • When I first started work on this PR I added a timeout interceptor that would be applied to all calls. Looking at it now, I think it makes more sense to be able to specify a timeout per method. Some things are expected to take longer than others, and control should be more granular. What do you think?

elena-kolevska avatar May 01 '24 20:05 elena-kolevska