Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh1994 committed Jan 3, 2025
1 parent 0ceba2f commit 039bff0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lazyllm/components/deploy/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import datetime
from datetime import datetime
import random
import lazyllm

Expand Down
2 changes: 1 addition & 1 deletion lazyllm/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def make_shared_llm(llm: str, local: bool = True, prompt: Optional[str] = None,
def make_online_llm(source: str, base_model: Optional[str] = None, prompt: Optional[str] = None,
api_key: Optional[str] = None, secret_key: Optional[str] = None,
stream: bool = False, token: Optional[str] = None, base_url: Optional[str] = None):
if source.lower() == 'lazyllm':
if source and source.lower() == 'lazyllm':
return make_shared_llm(base_model, False, prompt, token, stream)
else:
return lazyllm.OnlineChatModule(base_model, source, base_url, stream,
Expand Down
26 changes: 26 additions & 0 deletions lazyllm/tools/infer_service/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from urllib.parse import urljoin
import requests
import lazyllm
Expand Down Expand Up @@ -124,3 +125,28 @@ def get_infra_handle(self, token, job_id):
if not (deployer := getattr(lazyllm.deploy, deploy_method, None)):
deployer = type(lazyllm.deploy.auto(base_model))
return lazyllm.TrainableModule(base_model).deploy_method(deployer, url=url)

def wait_ready(self, token, job_id, timeout=1800):
'''
This method to wait for a specific job based on the provided job ID.
Parameters:
- token(str): A string representing the authentication token required to access the job details.
- job_id(str): The unique identifier for the job whose details need to be retrieved.
Returns:
- infer service status.
'''
def get_status():
response = requests.get(urljoin(self.url, f'jobs/{job_id}'), headers={'token': token})
response.raise_for_status()
response = response.json()
return self.uniform_status(response['status'])

n = 0
while (status := get_status()) != 'Running':
if status in ('Invalid', 'Cancelled', 'Failed'):
raise RuntimeError(f'Deploy service failed. status is {status}')
if n > timeout: raise TimeoutError('Inference service has not started after 1800 seconds.')
time.sleep(10)
n += 10
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ docx2txt
olefile
pytest-rerunfailures
pytest-order
pymilvus>=2.4.7, <2.4.11
pymilvus==2.4.10
milvus-lite==2.4.10
openpyxl
nbconvert
python-pptx
Expand Down

0 comments on commit 039bff0

Please sign in to comment.