Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I'm trying to add a percent-based jitter function to the backoff package and use that modified package in my project instead of the PyPI release. Current jitter algorithm I want to implement (from...
#5: Post edited
How to add a percent_jitter strategy to backoff/_jitter.py and pass extra args to the decorator?
- How to add a percent_jitter strategy to backoff Python package and pass extra args in the decorator?
- I'm trying to add a percent-based jitter function to the [backoff package](https://pypi.org/project/backoff) and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).- 2. How can I install and use my modified version in my project instead of the PyPI package?
- 3. Alternatively, if modifying the library is too complex, how can I use this custom jitter function with the original backoff package?
- I'm trying to add a percent-based jitter function to the [backoff package](https://pypi.org/project/backoff) and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The [existing jitter functions](https://github.com/litl/backoff/blob/master/backoff/_jitter.py) are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
- 2. How can I install and use my modified version in my project instead of the PyPI package?
- 3. Alternatively, if modifying the library is too complex, how can I use this custom jitter function with the original backoff package?
#4: Post edited
- I'm trying to add a percent-based jitter function to the [backoff package](https://pypi.org/project/backoff) and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
2. How can I install and use my modified version in my project instead of the PyPI package?
- I'm trying to add a percent-based jitter function to the [backoff package](https://pypi.org/project/backoff) and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
- 2. How can I install and use my modified version in my project instead of the PyPI package?
- 3. Alternatively, if modifying the library is too complex, how can I use this custom jitter function with the original backoff package?
#3: Post edited
I'm trying to add a percent-based jitter function to the backoff package and use that modified package in my project instead of the PyPI release.Current jitter algorithm I want to implement (from Stack Overflow):- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
2. How can I install and use my modified version in my project instead of the PyPI package (options like editable install, installing from a local VCS repo, or publishing a private wheel)?
- I'm trying to add a percent-based jitter function to the [backoff package](https://pypi.org/project/backoff) and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
- 2. How can I install and use my modified version in my project instead of the PyPI package?
#2: Post edited
I want to add a new jitter strategy to backoff at: https://github.com/litl/backoff/blob/master/backoff/_jitter.py- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
The existing jitter functions are called with only the backoff value. How can I modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter?
- I'm trying to add a percent-based jitter function to the backoff package and use that modified package in my project instead of the PyPI release.
- Current jitter algorithm I want to implement (from Stack Overflow):
- https://stackoverflow.com/q/46939285
- Proposed function:
- ```py
- def percent_jitter(value: float, percentage: float = 0.2) -> float:
- max_jitter = value * percentage
- return value + random.uniform(-max_jitter, max_jitter)
- ```
- Questions:
- 1. What is the best way to modify the backoff package source to add this percent_jitter function? The existing jitter functions are called with only the backoff value. I would need to modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter(percentage={input}).
- 2. How can I install and use my modified version in my project instead of the PyPI package (options like editable install, installing from a local VCS repo, or publishing a private wheel)?
#1: Initial revision
How to add a percent_jitter strategy to backoff/_jitter.py and pass extra args to the decorator?
I want to add a new jitter strategy to backoff at: https://github.com/litl/backoff/blob/master/backoff/_jitter.py
Proposed function:
```py
def percent_jitter(value: float, percentage: float = 0.2) -> float:
max_jitter = value * percentage
return value + random.uniform(-max_jitter, max_jitter)
```
The existing jitter functions are called with only the backoff value. How can I modify the library so a jitter function can accept an extra parameter (like percentage) and let users pass that parameter when applying the @backoff.on_exception with jitter=percent_jitter?
