Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
f6dbd240
Commit
f6dbd240
authored
Jun 08, 2024
by
Lianmin Zheng
Browse files
Improve doc strings (#518)
parent
e8a2327d
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
python/sglang/srt/server.py
python/sglang/srt/server.py
+12
-4
python/sglang/test/test_programs.py
python/sglang/test/test_programs.py
+1
-3
No files found.
python/sglang/srt/server.py
View file @
f6dbd240
"""SRT: SGLang Runtime"""
"""
The entry point of inference server.
SRT = SGLang Runtime.
"""
import
asyncio
import
asyncio
import
dataclasses
import
dataclasses
...
@@ -10,7 +13,7 @@ import sys
...
@@ -10,7 +13,7 @@ import sys
import
threading
import
threading
import
time
import
time
from
http
import
HTTPStatus
from
http
import
HTTPStatus
from
typing
import
Optional
from
typing
import
Optional
,
Dict
# Fix a bug of Python threading
# Fix a bug of Python threading
setattr
(
threading
,
"_register_atexit"
,
lambda
*
args
,
**
kwargs
:
None
)
setattr
(
threading
,
"_register_atexit"
,
lambda
*
args
,
**
kwargs
:
None
)
...
@@ -148,7 +151,6 @@ def launch_server(server_args: ServerArgs, pipe_finish_writer, model_overide_arg
...
@@ -148,7 +151,6 @@ def launch_server(server_args: ServerArgs, pipe_finish_writer, model_overide_arg
server_args
.
dp_size
,
server_args
.
dp_size
,
)
)
# Init local models port args
ports
=
server_args
.
additional_ports
ports
=
server_args
.
additional_ports
tp
=
server_args
.
tp_size
tp
=
server_args
.
tp_size
model_port_args
=
[]
model_port_args
=
[]
...
@@ -269,6 +271,12 @@ def launch_server(server_args: ServerArgs, pipe_finish_writer, model_overide_arg
...
@@ -269,6 +271,12 @@ def launch_server(server_args: ServerArgs, pipe_finish_writer, model_overide_arg
class
Runtime
:
class
Runtime
:
"""
A wrapper for the server.
This is used for launching the server in a python program without
using the commond line interface.
"""
def
__init__
(
def
__init__
(
self
,
self
,
log_level
:
str
=
"error"
,
log_level
:
str
=
"error"
,
...
@@ -339,7 +347,7 @@ class Runtime:
...
@@ -339,7 +347,7 @@ class Runtime:
async
def
add_request
(
async
def
add_request
(
self
,
self
,
prompt
:
str
,
prompt
:
str
,
sampling_params
,
sampling_params
:
Dict
,
):
):
json_data
=
{
json_data
=
{
"text"
:
prompt
,
"text"
:
prompt
,
...
...
python/sglang/test/test_programs.py
View file @
f6dbd240
"""
"""This file contains the SGL programs used for unit testing."""
This file contains the SGL programs used for unit testing.
"""
import
json
import
json
import
re
import
re
...
...
Prev
1
2
Next
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