From a3083fa592a16a665efbd189d87dace266682de2 Mon Sep 17 00:00:00 2001 From: Wyatt Pearsall Date: Tue, 16 Jun 2026 10:51:01 -0700 Subject: [PATCH 1/2] Add a pool maxsize and remove superfluous connection method --- complaint_search/es_interface.py | 40 +++++++++++--------------------- setup.py | 2 -- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/complaint_search/es_interface.py b/complaint_search/es_interface.py index 48be4d8..544d17a 100644 --- a/complaint_search/es_interface.py +++ b/complaint_search/es_interface.py @@ -6,8 +6,7 @@ from urllib.parse import quote from flags.state import flag_enabled -from opensearchpy import OpenSearch, RequestsHttpConnection, helpers -from requests_aws4auth import AWS4Auth +from opensearchpy import OpenSearch, helpers from complaint_search.defaults import ( CSV_ORDERED_HEADERS, @@ -36,7 +35,6 @@ _ES_PASSWORD = os.environ.get("ES_PASSWORD", "") _ES_INSTANCE = None -USE_AWS_ES = os.environ.get("USE_AWS_ES", False) AWS_ES_ACCESS_KEY = os.environ.get("AWS_ES_ACCESS_KEY") AWS_ES_SECRET_KEY = os.environ.get("AWS_ES_SECRET_KEY") AWS_ES_HOST = os.environ.get("ES_HOST") @@ -144,30 +142,18 @@ def process_trends_response(response): def _get_es(): global _ES_INSTANCE if _ES_INSTANCE is None: - if USE_AWS_ES: # pragma: no cover - awsauth = AWS4Auth( - AWS_ES_ACCESS_KEY, AWS_ES_SECRET_KEY, "us-east-1", "es" - ) - _ES_INSTANCE = OpenSearch( - hosts=[{"host": AWS_ES_HOST, "port": 443}], - http_auth=awsauth, - use_ssl=True, - verify_certs=True, - connection_class=RequestsHttpConnection, - timeout=100, - ) - else: - host = _ES_HOST - if _ES_USER and _ES_PASSWORD: - encoded_username = quote(_ES_USER) - encoded_password = quote(_ES_PASSWORD) - host = f"{encoded_username}:{encoded_password}@{host}" - - _ES_INSTANCE = OpenSearch( - f"http://{host}:{_ES_PORT}", - use_ssl=(str(_ES_PORT) == "443"), - timeout=100 - ) + host = _ES_HOST + if _ES_USER and _ES_PASSWORD: + encoded_username = quote(_ES_USER) + encoded_password = quote(_ES_PASSWORD) + host = f"{encoded_username}:{encoded_password}@{host}" + + _ES_INSTANCE = OpenSearch( + f"http://{host}:{_ES_PORT}", + use_ssl=(str(_ES_PORT) == "443"), + timeout=100, + pool_maxsize=10 + ) return _ES_INSTANCE diff --git a/setup.py b/setup.py index 95c7f3c..b63c050 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,6 @@ def get_git_version(): "opensearch-py>=2.1.0,<=3.0.0", "django-localflavor>=4.0,<5.0", "django-flags>=5", - "requests-aws4auth", ] testing_extras = [ @@ -62,7 +61,6 @@ def get_git_version(): "deep==0.10", "deepdiff>=6.7,<7", "parameterized==0.9.0", - "requests-aws4auth", ] From bb5b9246d23fe2a3d7f86d24728d741b4cc2f83c Mon Sep 17 00:00:00 2001 From: Wyatt Pearsall Date: Tue, 16 Jun 2026 10:55:42 -0700 Subject: [PATCH 2/2] Trim extra vars --- complaint_search/es_interface.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/complaint_search/es_interface.py b/complaint_search/es_interface.py index 544d17a..8649cd6 100644 --- a/complaint_search/es_interface.py +++ b/complaint_search/es_interface.py @@ -35,10 +35,6 @@ _ES_PASSWORD = os.environ.get("ES_PASSWORD", "") _ES_INSTANCE = None -AWS_ES_ACCESS_KEY = os.environ.get("AWS_ES_ACCESS_KEY") -AWS_ES_SECRET_KEY = os.environ.get("AWS_ES_SECRET_KEY") -AWS_ES_HOST = os.environ.get("ES_HOST") - _COMPLAINT_ES_INDEX = os.environ.get("COMPLAINT_ES_INDEX", "complaint-index")