-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into count-lines-for-regex
- Loading branch information
Showing
27 changed files
with
472 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[flake8] | ||
ignore = E501,W503,E203 | ||
exclude = .git,__pycache__,venv | ||
disable = W391 | ||
exclude = .git,__pycache__,venv,.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import logging | ||
import time | ||
from functools import wraps | ||
|
||
|
||
def retry_on_traceback(max_attempts=10, wait_seconds=1): | ||
""" | ||
Retries a function until it succeeds or the maximum number of attempts | ||
or wait time is reached. | ||
This is to mimic `@retry` decorator from Tenacity so we do not depend | ||
on it. | ||
Args: | ||
max_attempts: The maximum number of attempts to retry the function. | ||
wait_seconds: The number of seconds to wait between retries. | ||
Returns: | ||
A decorator that retries the wrapped function. | ||
""" | ||
assert max_attempts >= 0, "It does not make sense to have less than 0 retries" | ||
assert wait_seconds >= 0, "It does not make sense to wait les than 0 seconds" | ||
|
||
def decorator(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
attempt = 0 | ||
while True: | ||
try: | ||
return func(*args, **kwargs) | ||
except Exception as e: | ||
if attempt >= max_attempts: | ||
raise # Reraise the exception after all retries are exhausted | ||
|
||
attempt += 1 | ||
logging.debug( | ||
f"Retrying in {wait_seconds} seconds. Attempt {attempt}/{max_attempts} failed with: {e}" | ||
) | ||
time.sleep(wait_seconds) | ||
|
||
return wrapper | ||
|
||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ | |
"requests", | ||
"tabulate", | ||
"deepdiff", | ||
"tenacity", | ||
], | ||
package_data={ | ||
"opl": [ | ||
|
Oops, something went wrong.