@@ -648,40 +648,6 @@ def require_flash_attn_3(test_case):
648648 return unittest .skipUnless (is_flash_attn_3_available (), "test requires Flash Attention 3" )(test_case )
649649
650650
651- def require_read_token (test_case ):
652- """
653- A decorator that loads the HF token for tests that require to load gated models.
654- """
655- token = os .getenv ("HF_HUB_READ_TOKEN" )
656-
657- if isinstance (test_case , type ):
658- for attr_name in dir (test_case ):
659- attr = getattr (test_case , attr_name )
660- if isinstance (attr , types .FunctionType ):
661- if getattr (attr , "__require_read_token__" , False ):
662- continue
663- wrapped = require_read_token (attr )
664- if isinstance (inspect .getattr_static (test_case , attr_name ), staticmethod ):
665- # Don't accidentally bind staticmethods to `self`
666- wrapped = staticmethod (wrapped )
667- setattr (test_case , attr_name , wrapped )
668- return test_case
669- else :
670- if getattr (test_case , "__require_read_token__" , False ):
671- return test_case
672-
673- @functools .wraps (test_case )
674- def wrapper (* args , ** kwargs ):
675- if token is not None :
676- with patch ("huggingface_hub.utils._headers.get_token" , return_value = token ):
677- return test_case (* args , ** kwargs )
678- else : # Allow running locally with the default token env variable
679- return test_case (* args , ** kwargs )
680-
681- wrapper .__require_read_token__ = True
682- return wrapper
683-
684-
685651def require_peft (test_case ):
686652 """
687653 Decorator marking a test that requires PEFT.
0 commit comments