From f6f33ee107ff5556f4cbff165af427929a690765 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Wed, 10 Sep 2025 14:32:05 +0200 Subject: [PATCH] chore(python): remove redundant check --- .../algoliasearch/http/retry.py | 2 +- playground/python/app/search.py | 79 ++++++++----------- playground/python/poetry.lock | 2 +- 3 files changed, 37 insertions(+), 46 deletions(-) diff --git a/clients/algoliasearch-client-python/algoliasearch/http/retry.py b/clients/algoliasearch-client-python/algoliasearch/http/retry.py index 8a5a48b34a7..68753ab11ec 100644 --- a/clients/algoliasearch-client-python/algoliasearch/http/retry.py +++ b/clients/algoliasearch-client-python/algoliasearch/http/retry.py @@ -33,7 +33,7 @@ def decide(self, host: Host, response: ApiResponse) -> str: host.up = False return RetryOutcome.RETRY - elif response.status_code is not None and self._is_success(response): + elif self._is_success(response): return RetryOutcome.SUCCESS return RetryOutcome.FAIL diff --git a/playground/python/app/search.py b/playground/python/app/search.py index 816e945228b..e113509ba71 100644 --- a/playground/python/app/search.py +++ b/playground/python/app/search.py @@ -1,57 +1,48 @@ -from os import environ - -from algoliasearch.search.client import SearchClientSync -from algoliasearch.search.config import SearchConfig from algoliasearch.search import __version__ +from algoliasearch.search.client import SearchClientSync, SearchClient +from algoliasearch.search.config import SearchConfig +from asyncio import run from dotenv import load_dotenv +from os import environ load_dotenv("../.env") -def main(): - print("SearchClient version", __version__) - - client = SearchClientSync( +# def main(): +# print("SearchClient version", __version__) +# +# client = SearchClientSync( +# environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY") +# ) +# client.add_user_agent("playground") +# client.add_user_agent("bar", "baz") +# +# print("user_agent", client._config._user_agent.get()) +# print("client initialized", client) +# +# try: +# resp = client.search_single_index("poussing-RECORDS") +# print(resp.to_dict()) +# finally: +# client.close() +# +# print("client closed") + + +async def asyncmain(): + client = SearchClient( environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY") ) - client.add_user_agent("playground") - client.add_user_agent("bar", "baz") - print("user_agent", client._config._user_agent.get()) print("client initialized", client) try: - resp = client.search_single_index("poussing-RECORDS") - print(resp.to_dict()) + await client.search_single_index("poussing-RECDS") + print("resp ok") finally: - client.close() - - print("client closed") - - # print("with transformations") - # - # config = SearchConfig( - # environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY") - # ) - # - # config.set_transformation_region("eu") - # - # print("region in playground") - # print(config.region) - # - # client = SearchClientSync.create_with_config(config) - # client.add_user_agent("playground search with ingestion") - # - # print("user_agent", client._config._user_agent.get()) - # - # try: - # resp = client.replace_all_objects_with_transformation( - # "boyd", [{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"},{"objectID": "bar"}], 2 - # ) - # print(resp) - # except Exception as e: - # print(e) - # finally: - # client.close() - # - # print("client closed") + await client.close() + + print("client closed", client) + + +run(asyncmain()) diff --git a/playground/python/poetry.lock b/playground/python/poetry.lock index 23fd4d14feb..6ee0d809368 100644 --- a/playground/python/poetry.lock +++ b/playground/python/poetry.lock @@ -142,7 +142,7 @@ frozenlist = ">=1.1.0" [[package]] name = "algoliasearch" -version = "4.25.0" +version = "4.26.0" description = "A fully-featured and blazing-fast Python API client to interact with Algolia." optional = false python-versions = ">= 3.8.1"