Skip to content

Remove tenacity dependency #4831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Removed
- Drop deprecated `pointcloud` and `heatmapgl` traces from the API
- Drop `tenacity` dependency [#4831](https://github.com/plotly/plotly.js/pull/4831)

### Updated

Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies:
- pandas
- black
- pytest
- tenacity
- inflect
- jupyterlab
- ipywidgets
Expand Down
37 changes: 30 additions & 7 deletions packages/python/plotly/plotly/io/_orca.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import atexit
import functools
import json
import os
import random
import socket
import subprocess
import sys
import threading
import time
import warnings
from copy import copy
from contextlib import contextmanager
from copy import copy
from pathlib import Path
from shutil import which

import tenacity

import plotly
from plotly.files import PLOTLY_DIR, ensure_writable_plotly_dir
from plotly.io._utils import validate_coerce_fig_to_dict
Expand Down Expand Up @@ -111,6 +112,31 @@ def find_open_port():
return port


def retry(min_wait=5, max_wait=10, max_delay=60000):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
start_time = time.time()

while True:
try:
return func(*args, **kwargs)
except Exception as e:
elapsed_time = time.time() - start_time
if elapsed_time * 1000 >= max_delay:
raise TimeoutError(
f"Retry limit of {max_delay} milliseconds reached."
) from e

wait_time = random.uniform(min_wait, max_wait)
print(f"Retrying in {wait_time:.2f} seconds due to {e}...")
time.sleep(wait_time)

return wrapper

return decorator


# Orca configuration class
# ------------------------
class OrcaConfig(object):
Expand Down Expand Up @@ -1357,10 +1383,7 @@ def ensure_server():
orca_state["shutdown_timer"] = t


@tenacity.retry(
wait=tenacity.wait_random(min=5, max=10),
stop=tenacity.stop_after_delay(60000),
)
@retry(min_wait=5, max_wait=10, max_delay=60000)
def request_image_with_retrying(**kwargs):
"""
Helper method to perform an image request to a running orca server process
Expand Down
1 change: 0 additions & 1 deletion packages/python/plotly/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ requirements:
- setuptools
run:
- python
- tenacity >=6.2.0

test:
imports:
Expand Down
3 changes: 0 additions & 3 deletions packages/python/plotly/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
### $ pip install -r requirements.txt ###
### ###
###################################################

## retrying requests ##
tenacity>=6.2.0
2 changes: 1 addition & 1 deletion packages/python/plotly/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def run(self):
data_files=[
("etc/jupyter/nbconfig/notebook.d", ["jupyterlab-plotly.json"]),
],
install_requires=["tenacity>=6.2.0", "packaging"],
install_requires=["packaging"],
zip_safe=False,
cmdclass=dict(
build_py=js_prerelease(versioneer_cmds["build_py"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests==2.25.1
tenacity==6.2.0
pytest==7.4.4
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.25.1
tenacity==6.2.0
pandas==1.5.3
numpy==1.23.0
xarray==0.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests==2.25.1
tenacity==6.2.0
pytest==7.4.4
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.25.1
tenacity==6.2.0
pandas==1.5.3
numpy==1.23.2
xarray==0.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests==2.25.1
tenacity==6.2.0
pytest==7.4.4
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.31.0
tenacity==8.2.3
pandas
xarray==2023.12.0
statsmodels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.31.0
tenacity==8.2.3
pandas
numpy
xarray==2023.12.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests==2.25.1
tenacity==6.2.0
pytest==8.1.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.25.1
tenacity==6.2.0
pandas==1.2.4
numpy==1.20.2
xarray==0.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests==2.25.1
tenacity==6.2.0
pytest==6.2.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.25.1
tenacity==6.2.0
pandas==1.2.4
numpy==1.21.6
xarray==0.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests==2.25.1
tenacity==6.2.0
pandas==2.2.0
numpy==1.22.4
xarray==0.17.0
Expand Down