Skip to content

Commit 16cb99d

Browse files
committed
fix: protection for opensearch_dsl being merged in opensearchpy
1 parent e597157 commit 16cb99d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ dependencies:
1919
- elasticsearch <7.14
2020
- elasticsearch-dsl
2121
- opensearch-py
22-
- opensearch-dsl
2322
- fts3
2423
- gitpython >=2.1.0
2524
- m2crypto >=0.38.0

src/DIRAC/Core/Utilities/ElasticSearchDB.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
import certifi
1414

1515
try:
16-
from opensearch_dsl import A, Q, Search
1716
from opensearchpy import OpenSearch as Elasticsearch
18-
from opensearchpy.exceptions import ConnectionError as ElasticConnectionError
19-
from opensearchpy.exceptions import NotFoundError, RequestError, TransportError, ConflictError
17+
from opensearchpy.exceptions import (
18+
ConnectionError as ElasticConnectionError,
19+
TransportError,
20+
NotFoundError,
21+
RequestError,
22+
ConflictError,
23+
)
2024
from opensearchpy.helpers import BulkIndexError, bulk
2125
except ImportError:
22-
from elasticsearch_dsl import Search, Q, A
2326
from elasticsearch import Elasticsearch
2427
from elasticsearch.exceptions import (
2528
ConnectionError as ElasticConnectionError,
@@ -30,6 +33,15 @@
3033
)
3134
from elasticsearch.helpers import BulkIndexError, bulk
3235

36+
try:
37+
try:
38+
from opensearchpy import A, Q, Search
39+
except ImportError:
40+
from opensearch_dsl import A, Q, Search
41+
except ImportError:
42+
from elasticsearch_dsl import Search, Q, A
43+
44+
3345
from DIRAC import S_ERROR, S_OK, gLogger
3446
from DIRAC.Core.Utilities import DErrno, TimeUtilities
3547
from DIRAC.FrameworkSystem.Client.BundleDeliveryClient import BundleDeliveryClient

0 commit comments

Comments
 (0)