Skip to content
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

Merge master onto dev branch. #243

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 5.29.10
current_version = 5.30.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion caveclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.29.10"
__version__ = "5.30.2"

from .frameworkclient import CAVEclient
from .session_config import get_session_defaults, set_session_defaults
Expand Down
44 changes: 36 additions & 8 deletions caveclient/session_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import logging
from typing import Collection, Optional, Union

import requests
from packaging.version import Version
from urllib3 import __version__ as urllib3_version
from urllib3.util.retry import Retry

SESSION_DEFAULTS = {}

if Version(urllib3_version) < Version("2.0.0"):
HAS_URLLIB3_V2 = False
else:
HAS_URLLIB3_V2 = True


def set_session_defaults(
max_retries: int = 3,
Expand Down Expand Up @@ -78,6 +86,17 @@ def set_session_defaults(
SESSION_DEFAULTS["backoff_max"] = backoff_max
SESSION_DEFAULTS["status_forcelist"] = status_forcelist

if not HAS_URLLIB3_V2 and backoff_max != 120:
logging.warning(
(
"`backoff_max` is only supported in urllib3 v2.0.0 and above "
"and will be ignored. "
"Please upgrade urllib3 to take advantage of this feature. "
"Note that this upgrade may conflict with other packages that depend on "
"urllib3, including `cloud-volume`."
)
)


set_session_defaults()

Expand Down Expand Up @@ -119,14 +138,23 @@ def _patch_session(
if pool_maxsize is None:
pool_maxsize = SESSION_DEFAULTS["pool_maxsize"]

retries = Retry(
total=max_retries,
backoff_factor=SESSION_DEFAULTS["backoff_factor"],
status_forcelist=SESSION_DEFAULTS["status_forcelist"],
allowed_methods=frozenset(["GET", "POST"]),
backoff_max=SESSION_DEFAULTS["backoff_max"],
raise_on_status=False,
)
if HAS_URLLIB3_V2:
retries = Retry(
total=max_retries,
backoff_factor=SESSION_DEFAULTS["backoff_factor"],
status_forcelist=SESSION_DEFAULTS["status_forcelist"],
allowed_methods=frozenset(["GET", "POST"]),
backoff_max=SESSION_DEFAULTS["backoff_max"],
raise_on_status=False,
)
else:
retries = Retry(
total=max_retries,
backoff_factor=SESSION_DEFAULTS["backoff_factor"],
status_forcelist=SESSION_DEFAULTS["status_forcelist"],
allowed_methods=frozenset(["GET", "POST"]),
raise_on_status=False,
)

http = requests.adapters.HTTPAdapter(
pool_maxsize=pool_maxsize,
Expand Down
10 changes: 0 additions & 10 deletions caveclient/skeletonservice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import logging
from io import BytesIO, StringIO
from typing import Literal, Optional

Expand All @@ -13,10 +12,6 @@

CLOUDVOLUME_AVAILABLE = True
except ImportError:
logging.warning(
"cloudvolume not installed. Some output formats will not be available."
)

CLOUDVOLUME_AVAILABLE = False

from .auth import AuthClient
Expand All @@ -26,11 +21,6 @@
SERVER_KEY = "skeleton_server_address"


"""
Usage
"""


class NoL2CacheException(Exception):
def __init__(self, value=""):
"""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy<2.0.0
pyarrow>=3
requests
urllib3>=2.0.2
urllib3
pandas<3.0.0
cachetools>=4.2.1
ipython
Expand Down
5 changes: 0 additions & 5 deletions tests/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,13 @@ def test_set_session_defaults(self):
pool_block = True
max_retries = 5
backoff_factor = 0.5
backoff_max = 240
status_forcelist = (502, 503, 504, 505)

set_session_defaults(
pool_maxsize=pool_maxsize,
pool_block=pool_block,
max_retries=max_retries,
backoff_factor=backoff_factor,
backoff_max=backoff_max,
status_forcelist=status_forcelist,
)
client = CAVEclient(
Expand All @@ -148,9 +146,6 @@ def test_set_session_defaults(self):
client.l2cache.session.adapters["https://"].max_retries.backoff_factor
== 0.5
)
assert (
client.l2cache.session.adapters["https://"].max_retries.backoff_max == 240
)
assert client.l2cache.session.adapters[
"https://"
].max_retries.status_forcelist == (
Expand Down
Loading