plaggy commited on
Commit
46093c3
·
1 Parent(s): c3d9b67

wakeup update

Browse files
Files changed (1) hide show
  1. embed_utils.py +13 -9
embed_utils.py CHANGED
@@ -13,7 +13,9 @@ logging.basicConfig(level=logging.INFO)
13
  logger = logging.getLogger(__name__)
14
 
15
  endpoint = get_inference_endpoint(env_config.tei_name, token=env_config.hf_token)
16
-
 
 
17
 
18
  async def embed_chunk(sentence, semaphore, tmp_file):
19
  async with semaphore:
@@ -47,16 +49,18 @@ async def embed_wrapper(input_ds, temp_file):
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
 
13
  logger = logging.getLogger(__name__)
14
 
15
  endpoint = get_inference_endpoint(env_config.tei_name, token=env_config.hf_token)
16
+ endpoint.resume().wait().fetch()
17
+ url = endpoint.url
18
+ a = 5
19
 
20
  async def embed_chunk(sentence, semaphore, tmp_file):
21
  async with semaphore:
 
49
 
50
 
51
  def wake_up_endpoint():
52
+ if endpoint.status != 'running':
53
+ logger.info("Starting up TEI endpoint")
54
+ endpoint.resume().wait().fetch()
55
+ n_loop = 0
56
+ while requests.get(
57
  url=endpoint.url,
58
  headers={"Authorization": f"Bearer {env_config.hf_token}"}
59
+ ).status_code != 200:
60
+ time.sleep(2)
61
+ n_loop += 1
62
+ if n_loop > 20:
63
+ raise TimeoutError("TEI endpoint is unavailable")
64
  logger.info("TEI endpoint is up")
65
 
66
  return