Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
14e3f9a1
"vscode:/vscode.git/clone" did not exist on "6e0c9d6bd07464b311eb098e2dac8196eed16721"
Unverified
Commit
14e3f9a1
authored
Mar 16, 2024
by
Ronen Schaffer
Committed by
GitHub
Mar 15, 2024
Browse files
Replace `lstrip()` with `removeprefix()` to fix Ruff linter warning (#2958)
parent
3123f151
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
benchmarks/backend_request_func.py
benchmarks/backend_request_func.py
+11
-4
pyproject.toml
pyproject.toml
+0
-2
No files found.
benchmarks/backend_request_func.py
View file @
14e3f9a1
...
...
@@ -64,7 +64,7 @@ async def async_request_tgi(
output
.
ttft
=
ttft
output
.
latency
=
time
.
perf_counter
()
-
st
body
=
data
.
decode
(
"utf-8"
)
.
lstrip
(
"data:"
)
body
=
remove_prefix
(
data
.
decode
(
"utf-8"
)
,
"data:"
)
output
.
generated_text
=
json
.
loads
(
body
)[
"generated_text"
]
output
.
success
=
True
else
:
...
...
@@ -158,7 +158,7 @@ async def async_request_trt_llm(
output
.
ttft
=
ttft
output
.
latency
=
time
.
perf_counter
()
-
st
body
=
data
.
decode
(
"utf-8"
)
.
lstrip
(
"data:"
)
body
=
remove_prefix
(
data
.
decode
(
"utf-8"
)
,
"data:"
)
output
.
generated_text
=
json
.
loads
(
body
)[
"text_output"
]
output
.
success
=
True
...
...
@@ -255,7 +255,7 @@ async def async_request_openai_completions(
if
not
chunk
:
continue
chunk
=
chunk
.
decode
(
"utf-8"
)
.
lstrip
(
"data: "
)
chunk
=
remove_prefix
(
chunk
.
decode
(
"utf-8"
)
,
"data: "
)
if
chunk
==
"[DONE]"
:
latency
=
time
.
perf_counter
()
-
st
else
:
...
...
@@ -322,7 +322,7 @@ async def async_request_openai_chat_completions(
if
not
chunk
:
continue
chunk
=
chunk
.
decode
(
"utf-8"
)
.
lstrip
(
"data: "
)
chunk
=
remove_prefix
(
chunk
.
decode
(
"utf-8"
)
,
"data: "
)
if
chunk
==
"[DONE]"
:
latency
=
time
.
perf_counter
()
-
st
else
:
...
...
@@ -344,6 +344,13 @@ async def async_request_openai_chat_completions(
return
output
# Since vllm must support Python 3.8, we can't use str.removeprefix(prefix) introduced in Python 3.9
def
remove_prefix
(
text
:
str
,
prefix
:
str
)
->
str
:
if
text
.
startswith
(
prefix
):
return
text
[
len
(
prefix
):]
return
text
ASYNC_REQUEST_FUNCS
=
{
"tgi"
:
async_request_tgi
,
"vllm"
:
async_request_vllm
,
...
...
pyproject.toml
View file @
14e3f9a1
...
...
@@ -33,8 +33,6 @@ ignore = [
"F405"
,
"F403"
,
# lambda expression assignment
"E731"
,
# .strip() with multi-character strings
"B005"
,
# Loop control variable not used within loop body
"B007"
,
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment