plaggy commited on
Commit
c3d9b67
1 Parent(s): f112799

wakeup update

Browse files
Files changed (1) hide show
  1. embed_utils.py +19 -4
embed_utils.py CHANGED
@@ -2,6 +2,7 @@ import json
2
  import asyncio
3
  import logging
4
  import time
 
5
 
6
  from tqdm.asyncio import tqdm_asyncio
7
  from huggingface_hub import get_inference_endpoint
@@ -46,9 +47,23 @@ async def embed_wrapper(input_ds, temp_file):
46
 
47
 
48
  def wake_up_endpoint():
49
- endpoint.fetch()
50
- if endpoint.status != 'running':
51
- logger.info("Starting up TEI endpoint")
52
- endpoint.resume().wait()
 
 
 
 
 
 
53
  logger.info("TEI endpoint is up")
 
54
  return
 
 
 
 
 
 
 
 
2
  import asyncio
3
  import logging
4
  import time
5
+ import requests
6
 
7
  from tqdm.asyncio import tqdm_asyncio
8
  from huggingface_hub import get_inference_endpoint
 
47
 
48
 
49
  def wake_up_endpoint():
50
+ logger.info("Starting up TEI endpoint")
51
+ n_loop = 0
52
+ while requests.get(
53
+ url=endpoint.url,
54
+ headers={"Authorization": f"Bearer {env_config.hf_token}"}
55
+ ).status_code != 200:
56
+ time.sleep(2)
57
+ n_loop += 1
58
+ if n_loop > 40:
59
+ raise TimeoutError("TEI endpoint is unavailable")
60
  logger.info("TEI endpoint is up")
61
+
62
  return
63
+
64
+ # endpoint.fetch()
65
+ # if endpoint.status != 'running':
66
+ # logger.info("Starting up TEI endpoint")
67
+ # endpoint.resume().wait()
68
+ # logger.info("TEI endpoint is up")
69
+ # return