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
0ad770c3
Unverified
Commit
0ad770c3
authored
Feb 29, 2024
by
Lucain
Committed by
GitHub
Feb 29, 2024
Browse files
Fix @require_read_token in tests (#29367)
parent
bb4f816a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
src/transformers/testing_utils.py
src/transformers/testing_utils.py
+2
-3
No files found.
src/transformers/testing_utils.py
View file @
0ad770c3
...
@@ -38,7 +38,6 @@ from typing import Callable, Dict, Iterable, Iterator, List, Optional, Union
...
@@ -38,7 +38,6 @@ from typing import Callable, Dict, Iterable, Iterator, List, Optional, Union
from
unittest
import
mock
from
unittest
import
mock
from
unittest.mock
import
patch
from
unittest.mock
import
patch
import
huggingface_hub
import
urllib3
import
urllib3
from
transformers
import
logging
as
transformers_logging
from
transformers
import
logging
as
transformers_logging
...
@@ -466,11 +465,11 @@ def require_read_token(fn):
...
@@ -466,11 +465,11 @@ def require_read_token(fn):
"""
"""
A decorator that loads the HF token for tests that require to load gated models.
A decorator that loads the HF token for tests that require to load gated models.
"""
"""
token
=
os
.
getenv
(
"HF_HUB_READ_TOKEN"
,
None
)
token
=
os
.
getenv
(
"HF_HUB_READ_TOKEN"
)
@
wraps
(
fn
)
@
wraps
(
fn
)
def
_inner
(
*
args
,
**
kwargs
):
def
_inner
(
*
args
,
**
kwargs
):
with
patch
.
object
(
huggingface_hub
.
utils
.
_headers
,
"
get_token"
,
return_value
=
token
):
with
patch
(
"
huggingface_hub.utils._headers
.
get_token"
,
return_value
=
token
):
return
fn
(
*
args
,
**
kwargs
)
return
fn
(
*
args
,
**
kwargs
)
return
_inner
return
_inner
...
...
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