From c739db26666b4dc544b69f75497b811b73602c32 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 10 Sep 2021 00:51:43 -0700 Subject: [PATCH 1/2] Do not retry on 500 errors Always install requests with socks Fixed typo and minor bug in flatness analysis --- kentik_api_library/kentik_api/analytics/flatness.py | 4 ++-- .../kentik_api/api_connection/retryable_session.py | 3 ++- kentik_api_library/setup.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kentik_api_library/kentik_api/analytics/flatness.py b/kentik_api_library/kentik_api/analytics/flatness.py index c63462e8..5695fd8b 100644 --- a/kentik_api_library/kentik_api/analytics/flatness.py +++ b/kentik_api_library/kentik_api/analytics/flatness.py @@ -359,7 +359,7 @@ def flatness_analysis( :param data: DataFrame indexed by time ("ts" column) containing columns "link" and "bytes_out" or "bps_out. "link" column is expected to contain names of network links as : "bytes_out" columns (if present) is expected to contain total number of bytes transmitted via the link - "bps_out" column (if present) is expected to contain average outbound bandwith in bits/s for the link + "bps_out" column (if present) is expected to contain average outbound bandwidth in bits/s for the link For "bytes_out" and "bps_out" the value is for a time period ending at the timestamp. If the "bps_out" column is present it is used as the source for the analysis (regardless of presence of "bytes_out") @@ -374,7 +374,7 @@ def flatness_analysis( log.debug("Computing bandwidth via each link") if not has_uniform_datetime_index(data): resolution = min_index_resolution(data).total_seconds() - log.info("Retrieved data have non-uniform sampling (min resolution: %f seconds) - resampling") + log.info("Retrieved data have non-uniform sampling (min resolution: %f seconds) - resampling", resolution) data = resample_volume_data(data, f"{resolution}S") link_bw = compute_link_bandwidth(data) else: diff --git a/kentik_api_library/kentik_api/api_connection/retryable_session.py b/kentik_api_library/kentik_api/api_connection/retryable_session.py index b0222c2a..0c542592 100755 --- a/kentik_api_library/kentik_api/api_connection/retryable_session.py +++ b/kentik_api_library/kentik_api/api_connection/retryable_session.py @@ -6,12 +6,13 @@ log = logging.getLogger(__name__) + # mypy: ignore-errors class RetryableSession(Session): DEFAULT_RETRY_STRATEGY = Retry( total=3, backoff_factor=1, - status_forcelist=[429, 500, 502, 503, 504], + status_forcelist=[429, 502, 503, 504], allowed_methods=["DELETE", "HEAD", "GET", "PUT", "OPTIONS", "PATCH", "POST"], ) diff --git a/kentik_api_library/setup.py b/kentik_api_library/setup.py index 52edf762..8a96bbd8 100644 --- a/kentik_api_library/setup.py +++ b/kentik_api_library/setup.py @@ -102,7 +102,7 @@ def run(self): url="https://github.com/kentik/community_sdk_python/tree/main/kentik_api_library", license="Apache-2.0", include_package_data=True, - install_requires=["dacite>=1.6.0", "requests>=2.25.0", "typing-extensions>=3.7.4.3"], + install_requires=["dacite>=1.6.0", "requests[socks]>=2.25.0", "typing-extensions>=3.7.4.3"], setup_requires=["pytest-runner", "pylint-runner", "setuptools_scm", "wheel"], tests_require=["httpretty", "pytest", "pylint"], extras_require={ From 1cb1fab470a3be2013f71a035c951845258ec954 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 20 Oct 2021 14:57:35 -0700 Subject: [PATCH 2/2] Added minimum version of urrlib3 to install_requirements Retry object has changed in version 1.26.0 and the SDK relies on the new version --- kentik_api_library/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kentik_api_library/setup.py b/kentik_api_library/setup.py index 8a96bbd8..ce380c64 100644 --- a/kentik_api_library/setup.py +++ b/kentik_api_library/setup.py @@ -102,7 +102,7 @@ def run(self): url="https://github.com/kentik/community_sdk_python/tree/main/kentik_api_library", license="Apache-2.0", include_package_data=True, - install_requires=["dacite>=1.6.0", "requests[socks]>=2.25.0", "typing-extensions>=3.7.4.3"], + install_requires=["dacite>=1.6.0", "requests[socks]>=2.25.0", "typing-extensions>=3.7.4.3", "urllib3>=1.26.0"], setup_requires=["pytest-runner", "pylint-runner", "setuptools_scm", "wheel"], tests_require=["httpretty", "pytest", "pylint"], extras_require={