Skip to content

Commit 2fd89bd

Browse files
committed
fix formatting
1 parent 7ee3846 commit 2fd89bd

File tree

9 files changed

+27
-35
lines changed

9 files changed

+27
-35
lines changed

elasticsearch/vectorstore/_async/strategies.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any, Dict, List, Literal, Optional, Union, cast
44

55
from elasticsearch import AsyncElasticsearch
6-
76
from elasticsearch.vectorstore._async._utils import model_must_be_deployed
87
from elasticsearch.vectorstore._async.embedding_service import AsyncEmbeddingService
98

elasticsearch/vectorstore/_async/vectorestore.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
from elasticsearch import AsyncElasticsearch
66
from elasticsearch.helpers import BulkIndexError, async_bulk
7-
8-
from elasticsearch.vectorstore._utils import (
9-
maximal_marginal_relevance,
10-
)
117
from elasticsearch.vectorstore._async.embedding_service import AsyncEmbeddingService
128
from elasticsearch.vectorstore._async.strategies import RetrievalStrategy
9+
from elasticsearch.vectorstore._utils import maximal_marginal_relevance
1310

1411
logger = logging.getLogger(__name__)
1512

examples/bulk-ingest/bulk-ingest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
"""Script that downloads a public dataset and streams it to an Elasticsearch cluster"""
77

88
import csv
9-
from os.path import abspath, join, dirname, exists
9+
from os.path import abspath, dirname, exists, join
10+
1011
import tqdm
1112
import urllib3
13+
1214
from elasticsearch import Elasticsearch
1315
from elasticsearch.helpers import streaming_bulk
1416

15-
1617
NYC_RESTAURANTS = (
1718
"https://data.cityofnewyork.us/api/views/43nn-pn8j/rows.csv?accessType=DOWNLOAD"
1819
)
@@ -99,7 +100,9 @@ def main():
99100
progress = tqdm.tqdm(unit="docs", total=number_of_docs)
100101
successes = 0
101102
for ok, action in streaming_bulk(
102-
client=client, index="nyc-restaurants", actions=generate_actions(),
103+
client=client,
104+
index="nyc-restaurants",
105+
actions=generate_actions(),
103106
):
104107
progress.update(1)
105108
successes += ok

examples/fastapi-apm/app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
# See the LICENSE file in the project root for more information
44

5-
import aiohttp
65
import datetime
76
import os
7+
8+
import aiohttp
9+
from elasticapm.contrib.starlette import ElasticAPM, make_apm_client
810
from fastapi import FastAPI
911
from fastapi.encoders import jsonable_encoder
12+
1013
from elasticsearch import AsyncElasticsearch, NotFoundError
1114
from elasticsearch.helpers import async_streaming_bulk
12-
from elasticapm.contrib.starlette import ElasticAPM, make_apm_client
13-
1415

1516
apm = make_apm_client(
1617
{"SERVICE_NAME": "fastapi-app", "SERVER_URL": "http://apm-server:8200"}
@@ -60,7 +61,9 @@ async def search(query):
6061

6162
@app.get("/delete")
6263
async def delete():
63-
return await client.delete_by_query(index="games", body={"query": {"match_all": {}}})
64+
return await client.delete_by_query(
65+
index="games", body={"query": {"match_all": {}}}
66+
)
6467

6568

6669
@app.get("/delete/{id}")

examples/fastapi-apm/ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# See the LICENSE file in the project root for more information
44

55
import random
6-
import urllib3
76
import time
87

8+
import urllib3
99

1010
endpoints = [
1111
"http://app:9292/",

test_elasticsearch/test_server/test_vectorstore/_async/_test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
2-
from typing import Any, Dict, List, Optional, AsyncIterator
2+
from typing import Any, AsyncIterator, Dict, List, Optional
33

44
from elastic_transport import AsyncTransport
5-
from elasticsearch import AsyncElasticsearch
65

6+
from elasticsearch import AsyncElasticsearch
77
from elasticsearch.vectorstore._async.embedding_service import AsyncEmbeddingService
88

99

test_elasticsearch/test_server/test_vectorstore/_async/test_embedding_service.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import os
2+
from typing import AsyncIterator
23

34
import pytest
4-
55
import pytest_asyncio
6-
from elasticsearch import AsyncElasticsearch
7-
8-
from typing import AsyncIterator
96

7+
from elasticsearch import AsyncElasticsearch
108
from elasticsearch.vectorstore._async._utils import model_is_deployed
11-
12-
from ._test_utils import (
13-
es_client_fixture,
14-
)
15-
169
from elasticsearch.vectorstore._async.embedding_service import (
1710
AsyncElasticsearchEmbeddings,
1811
)
1912

13+
from ._test_utils import es_client_fixture
14+
2015
# deployed with
2116
# https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-text-emb-vector-search-example.html
2217
MODEL_ID = os.getenv("MODEL_ID", "sentence-transformers__msmarco-minilm-l-12-v3")

test_elasticsearch/test_server/test_vectorstore/_async/test_vectorestore.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import logging
22
import uuid
3-
from typing import AsyncIterator
4-
from typing import Any, List, Optional, Union, cast
53
from functools import partial
4+
from typing import Any, AsyncIterator, List, Optional, Union, cast
65

76
import pytest
87
import pytest_asyncio
9-
from elasticsearch import AsyncElasticsearch
108

11-
from elasticsearch import NotFoundError
9+
from elasticsearch import AsyncElasticsearch, NotFoundError
1210
from elasticsearch.helpers import BulkIndexError
13-
1411
from elasticsearch.vectorstore._async import AsyncVectorStore
1512
from elasticsearch.vectorstore._async._utils import model_is_deployed
1613
from elasticsearch.vectorstore._async.strategies import (
@@ -22,11 +19,11 @@
2219
)
2320

2421
from ._test_utils import (
25-
create_requests_saving_client,
26-
es_client_fixture,
2722
AsyncConsistentFakeEmbeddings,
2823
AsyncFakeEmbeddings,
2924
AsyncRequestSavingTransport,
25+
create_requests_saving_client,
26+
es_client_fixture,
3027
)
3128

3229
logging.basicConfig(level=logging.DEBUG)
@@ -44,7 +41,7 @@
4441
- sentence-transformers__all-minilm-l6-v2 (can be deployed through the API,
4542
loaded via eland)
4643
47-
These tests that require the models to be deployed are skipped by default.
44+
These tests that require the models to be deployed are skipped by default.
4845
Enable them by adding the model name to the modelsDeployed list below.
4946
"""
5047

utils/run-unasync.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import os
1919
import subprocess
20-
from pathlib import Path
2120
from glob import glob
21+
from pathlib import Path
2222

2323
import unasync
2424

@@ -55,7 +55,6 @@ def run(rule: unasync.Rule, cleanup_patterns: list[str] = []):
5555

5656

5757
def main():
58-
5958
run(
6059
rule=unasync.Rule(
6160
fromdir="/elasticsearch/_async/client/",
@@ -98,7 +97,6 @@ def main():
9897
fromdir="test_elasticsearch/test_server/test_vectorstore/_async/",
9998
todir="test_elasticsearch/test_server/test_vectorstore/_sync/",
10099
additional_replacements={
101-
# Main
102100
"_async": "_sync",
103101
"async_bulk": "bulk",
104102
"AsyncElasticsearch": "Elasticsearch",

0 commit comments

Comments
 (0)