Chore (python): Better retry loop logging when embedding api fails (#1267)

https://github.com/lancedb/lancedb/issues/1266#event-12703166915

This happens because openai API errors out with None values. The current
log level didn't really print out the msg on screen. Changed the log
level to warning, which better suits this case.

Also, retry loop can be disabled by setting `max_retries=0` (I'm not
sure if we should also set this as the default behaviour as hitting api
rate is quite common when ingesting large corpus)

```
func = get_registry().get("openai").create(max_retries=0)
````
This commit is contained in:
Ayush Chaurasia
2024-05-06 11:49:11 +05:30
committed by GitHub
parent e933de003d
commit 2f13fa225f

View File

@@ -255,7 +255,13 @@ def retry_with_exponential_backoff(
)
delay *= exponential_base * (1 + jitter * random.random())
logging.info("Retrying in %s seconds...", delay)
logging.warning(
"Error occurred: %s \n Retrying in %s seconds (retry %s of %s) \n",
e,
delay,
num_retries,
max_retries,
)
time.sleep(delay)
return wrapper