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
9ae1db0b
Unverified
Commit
9ae1db0b
authored
Sep 25, 2024
by
Lianmin Zheng
Committed by
GitHub
Sep 25, 2024
Browse files
[Fix] Ignore import error (#1513)
parent
37c5899f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
python/sglang/srt/model_executor/model_runner.py
python/sglang/srt/model_executor/model_runner.py
+11
-3
No files found.
python/sglang/srt/model_executor/model_runner.py
View file @
9ae1db0b
...
@@ -568,17 +568,25 @@ def import_model_classes():
...
@@ -568,17 +568,25 @@ def import_model_classes():
package
=
importlib
.
import_module
(
package_name
)
package
=
importlib
.
import_module
(
package_name
)
for
_
,
name
,
ispkg
in
pkgutil
.
iter_modules
(
package
.
__path__
,
package_name
+
"."
):
for
_
,
name
,
ispkg
in
pkgutil
.
iter_modules
(
package
.
__path__
,
package_name
+
"."
):
if
not
ispkg
:
if
not
ispkg
:
module
=
importlib
.
import_module
(
name
)
try
:
module
=
importlib
.
import_module
(
name
)
except
Exception
as
e
:
logger
.
warning
(
f
"Ignore import error when loading
{
name
}
. "
f
"
{
e
}
"
)
continue
if
hasattr
(
module
,
"EntryClass"
):
if
hasattr
(
module
,
"EntryClass"
):
entry
=
module
.
EntryClass
entry
=
module
.
EntryClass
if
isinstance
(
if
isinstance
(
entry
,
list
entry
,
list
):
# To support multiple model classes in one module
):
# To support multiple model classes in one module
for
tmp
in
entry
:
for
tmp
in
entry
:
assert
tmp
.
__name__
not
in
model_arch_name_to_cls
assert
(
tmp
.
__name__
not
in
model_arch_name_to_cls
),
f
"Duplicated model implementation for
{
tmp
.
__name__
}
"
model_arch_name_to_cls
[
tmp
.
__name__
]
=
tmp
model_arch_name_to_cls
[
tmp
.
__name__
]
=
tmp
else
:
else
:
assert
entry
.
__name__
not
in
model_arch_name_to_cls
assert
(
entry
.
__name__
not
in
model_arch_name_to_cls
),
f
"Duplicated model implementation for
{
entry
.
__name__
}
"
model_arch_name_to_cls
[
entry
.
__name__
]
=
entry
model_arch_name_to_cls
[
entry
.
__name__
]
=
entry
return
model_arch_name_to_cls
return
model_arch_name_to_cls
...
...
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