Skip to content

Commit 5b54c29

Browse files
Minor fixes for batch inference (#426)
* Fix file not found * progress fix * add tests * bump * typing
1 parent 69f8bcb commit 5b54c29

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

clients/python/llmengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.0.0b21"
15+
__version__ = "0.0.0b22"
1616

1717
import os
1818
from typing import Sequence

clients/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scale-llm-engine"
3-
version = "0.0.0.beta21"
3+
version = "0.0.0.beta22"
44
description = "Scale LLM Engine Python client"
55
license = "Apache-2.0"
66
authors = ["Phil Chen <phil.chen@scale.com>"]

clients/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
setup(
44
name="scale-llm-engine",
55
python_requires=">=3.7",
6-
version="0.0.0.beta21",
6+
version="0.0.0.beta22",
77
packages=find_packages(),
88
)

model-engine/model_engine_server/inference/batch_inference/vllm_batch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def file_exists(path):
4848
try:
4949
with smart_open.open(path, "r"):
5050
return True
51-
except FileNotFoundError:
51+
except Exception as exc:
52+
print(f"Error checking if file exists: {exc}")
5253
return False
5354

5455

@@ -124,7 +125,7 @@ async def batch_inference():
124125

125126
results_generators = await generate_with_vllm(request, content, model, job_index)
126127

127-
bar = tqdm(total=len(content.prompts), desc="Processed prompts")
128+
bar = tqdm(total=len(results_generators), desc="Processed prompts")
128129

129130
outputs = []
130131
for generator in results_generators:

model-engine/tests/unit/inference/test_vllm_batch.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import MagicMock, call, mock_open, patch
33

44
import pytest
5-
from model_engine_server.inference.batch_inference.vllm_batch import batch_inference
5+
from model_engine_server.inference.batch_inference.vllm_batch import batch_inference, file_exists
66

77

88
@pytest.mark.asyncio
@@ -272,3 +272,28 @@ def side_effect(key, default):
272272
mock_s3_client.delete_object.assert_has_calls(
273273
[call(Bucket="bucket", Key="key.0"), call(Bucket="bucket", Key="key.1")]
274274
)
275+
276+
277+
def test_file_exists():
278+
mock_open_func = mock_open()
279+
path = "test_path"
280+
281+
with patch(
282+
"model_engine_server.inference.batch_inference.vllm_batch.smart_open.open", mock_open_func
283+
):
284+
result = file_exists(path)
285+
286+
mock_open_func.assert_called_once_with(path, "r")
287+
assert result is True
288+
289+
290+
def test_file_exists_no_such_key():
291+
path = "test_path"
292+
293+
with patch(
294+
"model_engine_server.inference.batch_inference.vllm_batch.smart_open.open",
295+
side_effect=IOError("No such key"),
296+
):
297+
result = file_exists(path)
298+
299+
assert result is False

0 commit comments

Comments
 (0)