Skip to content

Commit c87a0a7

Browse files
authored
chore(python): remove redundant check (#5338)
1 parent 77f5326 commit c87a0a7

File tree

3 files changed

+37
-46
lines changed

3 files changed

+37
-46
lines changed

clients/algoliasearch-client-python/algoliasearch/http/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def decide(self, host: Host, response: ApiResponse) -> str:
3333
host.up = False
3434

3535
return RetryOutcome.RETRY
36-
elif response.status_code is not None and self._is_success(response):
36+
elif self._is_success(response):
3737
return RetryOutcome.SUCCESS
3838

3939
return RetryOutcome.FAIL

playground/python/app/search.py

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,48 @@
1-
from os import environ
2-
3-
from algoliasearch.search.client import SearchClientSync
4-
from algoliasearch.search.config import SearchConfig
51
from algoliasearch.search import __version__
2+
from algoliasearch.search.client import SearchClientSync, SearchClient
3+
from algoliasearch.search.config import SearchConfig
4+
from asyncio import run
65
from dotenv import load_dotenv
6+
from os import environ
77

88
load_dotenv("../.env")
99

1010

11-
def main():
12-
print("SearchClient version", __version__)
13-
14-
client = SearchClientSync(
11+
# def main():
12+
# print("SearchClient version", __version__)
13+
#
14+
# client = SearchClientSync(
15+
# environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY")
16+
# )
17+
# client.add_user_agent("playground")
18+
# client.add_user_agent("bar", "baz")
19+
#
20+
# print("user_agent", client._config._user_agent.get())
21+
# print("client initialized", client)
22+
#
23+
# try:
24+
# resp = client.search_single_index("poussing-RECORDS")
25+
# print(resp.to_dict())
26+
# finally:
27+
# client.close()
28+
#
29+
# print("client closed")
30+
31+
32+
async def asyncmain():
33+
client = SearchClient(
1534
environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY")
1635
)
17-
client.add_user_agent("playground")
18-
client.add_user_agent("bar", "baz")
1936

20-
print("user_agent", client._config._user_agent.get())
2137
print("client initialized", client)
2238

2339
try:
24-
resp = client.search_single_index("poussing-RECORDS")
25-
print(resp.to_dict())
40+
await client.search_single_index("poussing-RECDS")
41+
print("resp ok")
2642
finally:
27-
client.close()
28-
29-
print("client closed")
30-
31-
# print("with transformations")
32-
#
33-
# config = SearchConfig(
34-
# environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY")
35-
# )
36-
#
37-
# config.set_transformation_region("eu")
38-
#
39-
# print("region in playground")
40-
# print(config.region)
41-
#
42-
# client = SearchClientSync.create_with_config(config)
43-
# client.add_user_agent("playground search with ingestion")
44-
#
45-
# print("user_agent", client._config._user_agent.get())
46-
#
47-
# try:
48-
# resp = client.replace_all_objects_with_transformation(
49-
# "boyd", [{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"}], 2
50-
# )
51-
# print(resp)
52-
# except Exception as e:
53-
# print(e)
54-
# finally:
55-
# client.close()
56-
#
57-
# print("client closed")
43+
await client.close()
44+
45+
print("client closed", client)
46+
47+
48+
run(asyncmain())

playground/python/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)