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
chenpangpang
transformers
Commits
0bef4a27
Unverified
Commit
0bef4a27
authored
May 29, 2024
by
Matt
Committed by
GitHub
May 29, 2024
Browse files
Fix faulty rstrip in module loading (#31108)
parent
97a58a5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/dynamic_module_utils.py
src/transformers/dynamic_module_utils.py
+4
-1
No files found.
src/transformers/dynamic_module_utils.py
View file @
0bef4a27
...
@@ -198,7 +198,10 @@ def get_class_in_module(class_name: str, module_path: Union[str, os.PathLike]) -
...
@@ -198,7 +198,10 @@ def get_class_in_module(class_name: str, module_path: Union[str, os.PathLike]) -
Returns:
Returns:
`typing.Type`: The class looked for.
`typing.Type`: The class looked for.
"""
"""
name
=
os
.
path
.
normpath
(
module_path
).
rstrip
(
".py"
).
replace
(
os
.
path
.
sep
,
"."
)
name
=
os
.
path
.
normpath
(
module_path
)
if
name
.
endswith
(
".py"
):
name
=
name
[:
-
3
]
name
=
name
.
replace
(
os
.
path
.
sep
,
"."
)
module_spec
=
importlib
.
util
.
spec_from_file_location
(
name
,
location
=
Path
(
HF_MODULES_CACHE
)
/
module_path
)
module_spec
=
importlib
.
util
.
spec_from_file_location
(
name
,
location
=
Path
(
HF_MODULES_CACHE
)
/
module_path
)
module
=
sys
.
modules
.
get
(
name
)
module
=
sys
.
modules
.
get
(
name
)
if
module
is
None
:
if
module
is
None
:
...
...
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