Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 35 additions & 44 deletions playground/python/app/search.py
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion playground/python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.