Skip to content

Commit 5826a88

Browse files
style: ruff autofix (auto)
1 parent 7dca3b1 commit 5826a88

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/app/lifespan.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,33 @@ async def run_startup(app: FastAPI):
228228
)
229229
else:
230230
from auth.ibm_auth import admin_username_from_service_jwt
231+
231232
admin_username = admin_username_from_service_jwt(service_token)
232233
if not admin_username and OPENRAG_BOOTSTRAP_OS_SECURITY_ON_STARTUP:
233234
raise RuntimeError(
234235
"OPENRAG_SERVICE_TOKEN has no 'username' or 'sub' claim; "
235236
"cannot bootstrap OpenSearch security"
236237
)
237-
238+
238239
from utils.opensearch_init import wait_for_opensearch
239-
240+
240241
opensearch_client = clients.create_opensearch_client_from_jwt(service_token)
241242
try:
242-
await wait_for_opensearch(opensearch_client, max_retries=OPENSEARCH_WAIT_MAX_RETRIES)
243-
243+
await wait_for_opensearch(
244+
opensearch_client, max_retries=OPENSEARCH_WAIT_MAX_RETRIES
245+
)
246+
244247
if OPENRAG_BOOTSTRAP_OS_SECURITY_ON_STARTUP:
245248
from utils.opensearch_utils import setup_opensearch_security
249+
246250
logger.info("Bootstrapping OpenSearch security", admin_username=admin_username)
247-
await setup_opensearch_security(opensearch_client, admin_username=admin_username)
248-
logger.info("OpenSearch security bootstrap completed", admin_username=admin_username)
249-
251+
await setup_opensearch_security(
252+
opensearch_client, admin_username=admin_username
253+
)
254+
logger.info(
255+
"OpenSearch security bootstrap completed", admin_username=admin_username
256+
)
257+
250258
if OPENRAG_ENSURE_INDEX_REPLICAS_ON_STARTUP:
251259
try:
252260
from utils.opensearch_init import ensure_openrag_index_replicas

src/utils/embeddings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
logger = get_logger(__name__)
44

5+
56
async def create_index_body() -> dict:
67
"""Create a static index body configuration.
7-
8+
89
Returns:
910
OpenSearch index body configuration
1011
"""
@@ -17,7 +18,7 @@ async def create_index_body() -> dict:
1718
"settings": {
1819
"index": {"knn": True},
1920
"number_of_shards": OPENSEARCH_NUMBER_OF_SHARDS,
20-
"number_of_replicas": OPENSEARCH_NUMBER_OF_REPLICAS
21+
"number_of_replicas": OPENSEARCH_NUMBER_OF_REPLICAS,
2122
},
2223
"mappings": {
2324
"properties": {

src/utils/opensearch_init.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ async def init_index(opensearch_client=None, admin_username: str = None):
253253
)
254254
await _ensure_index_replicas(os_client, API_KEYS_INDEX_NAME)
255255

256-
257256
await configure_alerting_security()
258257

259258
except Exception as e:

tests/unit/test_embedding_fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
JVector/DiskANN method configuration with only the dimension varying per
99
embedding model.
1010
"""
11+
1112
from typing import Any, Dict
1213

1314
import pytest
@@ -99,7 +100,7 @@ class TestBuildKnnVectorFieldCallSitesMatch:
99100
def test_index_body_uses_helper_output(self) -> None:
100101
from config.settings import INDEX_BODY, VECTOR_DIM
101102

102-
chunk_field: Dict[str, Any] = INDEX_BODY["mappings"]["properties"]["chunk_embedding"]
103+
chunk_field: dict[str, Any] = INDEX_BODY["mappings"]["properties"]["chunk_embedding"]
103104
expected = build_knn_vector_field(VECTOR_DIM)
104105
assert chunk_field == expected
105106

0 commit comments

Comments
 (0)