From 2e25218c60d22a8b33111ffdc3aec456d9d531bc Mon Sep 17 00:00:00 2001 From: karyxx Date: Mon, 15 Jun 2026 21:35:48 +0530 Subject: [PATCH 1/2] Bypass Sedna network timeouts during local offline benchmarking Signed-off-by: karyxx --- benchmarking.py | 26 ++++++++++++++++++++++++++ core/cmd/benchmarking.py | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/benchmarking.py b/benchmarking.py index ba8c9315d..7c317651e 100644 --- a/benchmarking.py +++ b/benchmarking.py @@ -14,6 +14,7 @@ """main""" +import os import sys import argparse @@ -23,6 +24,31 @@ from core.__version__ import __version__ +try: + import sedna.service.client + original_http_request = sedna.service.client.http_request + LOGGER.info("Bypassing Sedna network timeouts is active.") + + def patched_http_request(url, *args, **kwargs): + """Bypass local/invalid HTTP endpoints to speed up offline runs.""" + should_bypass = os.getenv("BYPASS_TIMEOUTS", "1") == "1" + is_local_endpoint = ( + not url + or url.startswith("None") + or "127.0.0.1" in url + or "localhost" in url + ) + if should_bypass and is_local_endpoint: + raise ConnectionError("Connection refused.") + return original_http_request(url, *args, **kwargs) + + sedna.service.client.http_request = patched_http_request +except ImportError: + pass + + + + def main(): """ main command-line interface to ianvs""" try: diff --git a/core/cmd/benchmarking.py b/core/cmd/benchmarking.py index ba8c9315d..b82a2960b 100644 --- a/core/cmd/benchmarking.py +++ b/core/cmd/benchmarking.py @@ -14,6 +14,7 @@ """main""" +import os import sys import argparse @@ -22,6 +23,29 @@ from core.cmd.obj import BenchmarkingJob from core.__version__ import __version__ +try: + import sedna.service.client + original_http_request = sedna.service.client.http_request + LOGGER.info("Bypassing Sedna network timeouts is active.") + + def patched_http_request(url, *args, **kwargs): + """Bypass local/invalid HTTP endpoints to speed up offline runs.""" + should_bypass = os.getenv("BYPASS_TIMEOUTS", "1") == "1" + is_local_endpoint = ( + not url + or url.startswith("None") + or "127.0.0.1" in url + or "localhost" in url + ) + if should_bypass and is_local_endpoint: + raise ConnectionError("Connection refused.") + return original_http_request(url, *args, **kwargs) + + sedna.service.client.http_request = patched_http_request +except ImportError: + pass + + def main(): """ main command-line interface to ianvs""" From 75c9a1df775927679366f8e6f302a76a2481e83a Mon Sep 17 00:00:00 2001 From: karyxx Date: Tue, 16 Jun 2026 00:01:42 +0530 Subject: [PATCH 2/2] Refactor Sedna patch into a shared util function to adhere to DRY Signed-off-by: karyxx --- benchmarking.py | 27 +-------------------------- core/cmd/benchmarking.py | 25 +------------------------ core/common/utils.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 50 deletions(-) diff --git a/benchmarking.py b/benchmarking.py index 7c317651e..89fcdde80 100644 --- a/benchmarking.py +++ b/benchmarking.py @@ -14,7 +14,6 @@ """main""" -import os import sys import argparse @@ -23,31 +22,7 @@ from core.cmd.obj import BenchmarkingJob from core.__version__ import __version__ - -try: - import sedna.service.client - original_http_request = sedna.service.client.http_request - LOGGER.info("Bypassing Sedna network timeouts is active.") - - def patched_http_request(url, *args, **kwargs): - """Bypass local/invalid HTTP endpoints to speed up offline runs.""" - should_bypass = os.getenv("BYPASS_TIMEOUTS", "1") == "1" - is_local_endpoint = ( - not url - or url.startswith("None") - or "127.0.0.1" in url - or "localhost" in url - ) - if should_bypass and is_local_endpoint: - raise ConnectionError("Connection refused.") - return original_http_request(url, *args, **kwargs) - - sedna.service.client.http_request = patched_http_request -except ImportError: - pass - - - +utils.patch_sedna_timeouts() def main(): """ main command-line interface to ianvs""" diff --git a/core/cmd/benchmarking.py b/core/cmd/benchmarking.py index b82a2960b..89fcdde80 100644 --- a/core/cmd/benchmarking.py +++ b/core/cmd/benchmarking.py @@ -14,7 +14,6 @@ """main""" -import os import sys import argparse @@ -23,29 +22,7 @@ from core.cmd.obj import BenchmarkingJob from core.__version__ import __version__ -try: - import sedna.service.client - original_http_request = sedna.service.client.http_request - LOGGER.info("Bypassing Sedna network timeouts is active.") - - def patched_http_request(url, *args, **kwargs): - """Bypass local/invalid HTTP endpoints to speed up offline runs.""" - should_bypass = os.getenv("BYPASS_TIMEOUTS", "1") == "1" - is_local_endpoint = ( - not url - or url.startswith("None") - or "127.0.0.1" in url - or "localhost" in url - ) - if should_bypass and is_local_endpoint: - raise ConnectionError("Connection refused.") - return original_http_request(url, *args, **kwargs) - - sedna.service.client.http_request = patched_http_request -except ImportError: - pass - - +utils.patch_sedna_timeouts() def main(): """ main command-line interface to ianvs""" diff --git a/core/common/utils.py b/core/common/utils.py index e7ad65226..86daf7dbc 100644 --- a/core/common/utils.py +++ b/core/common/utils.py @@ -101,3 +101,29 @@ def load_module(url): sys.path.pop(0) except Exception as err: raise RuntimeError(f"load module(url={url}) failed, error: {err}") from err + + +def patch_sedna_timeouts(): + """Bypass Sedna network timeouts during local offline benchmarking.""" + if os.getenv("BYPASS_TIMEOUTS", "1") == "1": + try: + import sedna.service.client + from core.common.log import LOGGER + original_http_request = sedna.service.client.http_request + LOGGER.info("Bypassing Sedna network timeouts is active.") + + def patched_http_request(url, *args, **kwargs): + """Bypass local/invalid HTTP endpoints to speed up offline runs.""" + is_local_endpoint = ( + not url + or url.startswith("None") + or "127.0.0.1" in url + or "localhost" in url + ) + if is_local_endpoint: + raise ConnectionError("Connection refused.") + return original_http_request(url, *args, **kwargs) + + sedna.service.client.http_request = patched_http_request + except ImportError: + pass