Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
Signed-off-by: Prithvi Kannan <[email protected]>
  • Loading branch information
prithvikannan committed Oct 22, 2024
1 parent 1b17d84 commit 4cadcbc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/databricks_ai_bridge/genie.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import time
from datetime import datetime
from typing import Union
Expand Down Expand Up @@ -82,12 +83,12 @@ def poll_result():
)
if resp["status"] == "EXECUTING_QUERY":
sql = next(r for r in resp["attachments"] if "query" in r)["query"]["query"]
# print(f"SQL: {sql}")
logging.debug(f"SQL: {sql}")
return poll_query_results()
elif resp["status"] == "COMPLETED":
return next(r for r in resp["attachments"] if "text" in r)["text"]["content"]
else:
# print(f"Waiting...: {resp['status']}")
logging.debug(f"Waiting...: {resp['status']}")
time.sleep(5)

def poll_query_results():
Expand All @@ -101,10 +102,10 @@ def poll_query_results():
if state == "SUCCEEDED":
return _parse_query_result(resp)
elif state == "RUNNING" or state == "PENDING":
# print(f"Waiting for query result...")
logging.debug("Waiting for query result...")
time.sleep(5)
else:
# print(f"No query result: {resp['state']}")
logging.debug(f"No query result: {resp['state']}")
return None

return poll_result()
Expand Down

0 comments on commit 4cadcbc

Please sign in to comment.