From fc0a9ace22d37609a830e0fcea5adb308885455e Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Tue, 14 Jan 2025 14:19:50 +0100 Subject: [PATCH] fix: removed elastic in favor of opensearch client --- environment.yml | 2 - setup.cfg | 3 +- src/DIRAC/Core/Utilities/ElasticSearchDB.py | 43 +++++++-------------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/environment.yml b/environment.yml index c412023f70d..e1c89ff529b 100644 --- a/environment.yml +++ b/environment.yml @@ -17,8 +17,6 @@ dependencies: - cmreshandler >1.0.0b4 - cwltool - db12 - - elasticsearch <7.14 - - elasticsearch-dsl - opensearch-py - fts3 - gitpython >=2.1.0 diff --git a/setup.cfg b/setup.cfg index 718fb1dd3a0..c09cb5032d9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -70,8 +70,7 @@ server = # (it just installs into site-packages) # arc CMRESHandler - elasticsearch <7.14 - elasticsearch_dsl + opensearch-py GitPython ldap3 apache-libcloud diff --git a/src/DIRAC/Core/Utilities/ElasticSearchDB.py b/src/DIRAC/Core/Utilities/ElasticSearchDB.py index 273661a5a7f..2a5e05d70de 100644 --- a/src/DIRAC/Core/Utilities/ElasticSearchDB.py +++ b/src/DIRAC/Core/Utilities/ElasticSearchDB.py @@ -11,39 +11,22 @@ from urllib import parse as urlparse import certifi +from opensearchpy import OpenSearch as Elasticsearch +from opensearchpy.exceptions import ( + ConflictError, + NotFoundError, + RequestError, + TransportError, +) +from opensearchpy.exceptions import ( + ConnectionError as ElasticConnectionError, +) +from opensearchpy.helpers import BulkIndexError, bulk try: - from opensearchpy import OpenSearch as Elasticsearch - from opensearchpy.exceptions import ( - ConflictError, - NotFoundError, - RequestError, - TransportError, - ) - from opensearchpy.exceptions import ( - ConnectionError as ElasticConnectionError, - ) - from opensearchpy.helpers import BulkIndexError, bulk + from opensearchpy import A, Q, Search except ImportError: - from elasticsearch import Elasticsearch - from elasticsearch.exceptions import ( - ConflictError, - NotFoundError, - RequestError, - TransportError, - ) - from elasticsearch.exceptions import ( - ConnectionError as ElasticConnectionError, - ) - from elasticsearch.helpers import BulkIndexError, bulk - -try: - try: - from opensearchpy import A, Q, Search - except ImportError: - from opensearch_dsl import A, Q, Search -except ImportError: - from elasticsearch_dsl import A, Q, Search + from opensearch_dsl import A, Q, Search from DIRAC import S_ERROR, S_OK, gLogger