Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt committed Feb 20, 2025
1 parent 59dbbd2 commit a80c651
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions example-apps/chatbot-rag-app/data/index_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@


def install_elser():
# This script is re-entered on ctrl-c or someone just running it twice.
# Hence, both steps need to be careful about being potentially redundant.

# Step 1: Ensure ELSER_MODEL is defined
try:
es.ml.get_trained_models(model_id=ELSER_MODEL)
Expand All @@ -66,14 +69,9 @@ def install_elser():
)
print(f'"{ELSER_MODEL}" model is deployed')
except BadRequestError:
# Already started
# Already started, and likely fully allocated
pass

while True:
if is_elser_fully_allocated():
break
time.sleep(1)

print(f'"{ELSER_MODEL}" model is ready')


Expand Down Expand Up @@ -127,8 +125,8 @@ def main():

print(f"Adding documents to index {INDEX}")

spinner = Halo(text="Processing bulk operation", spinner="dots")
if stdout.isatty():
spinner = Halo(text="Processing bulk operation", spinner="dots")
spinner.start()

try:
Expand Down Expand Up @@ -175,10 +173,9 @@ def await_ml_tasks(max_timeout=600, interval=5):
return
time.sleep(interval)

if ml_tasks:
raise TimeoutError(
f"Timeout reached. ML tasks are still running: {', '.join(ml_tasks)}"
)
raise TimeoutError(
f"Timeout reached. ML tasks are still running: {', '.join(ml_tasks)}"
)


def get_ml_tasks():
Expand Down

0 comments on commit a80c651

Please sign in to comment.