2020import os .path
2121import sys
2222import tempfile
23- import threading
2423import unittest
2524import unittest .mock as mock
2625import uuid
@@ -1429,7 +1428,7 @@ def test_safetensors_on_the_fly_wrong_user_opened_pr(self):
14291428 bot_opened_pr_title = None
14301429
14311430 for discussion in discussions :
1432- if discussion .author == "SFconvertbot " :
1431+ if discussion .author == "SFconvertBot " :
14331432 bot_opened_pr = True
14341433 bot_opened_pr_title = discussion .title
14351434
@@ -1452,51 +1451,6 @@ def test_safetensors_on_the_fly_specific_revision(self):
14521451 with self .assertRaises (EnvironmentError ):
14531452 BertModel .from_pretrained (self .repo_name , use_safetensors = True , token = self .token , revision = "new-branch" )
14541453
1455- def test_absence_of_safetensors_triggers_conversion (self ):
1456- config = BertConfig (
1457- vocab_size = 99 , hidden_size = 32 , num_hidden_layers = 5 , num_attention_heads = 4 , intermediate_size = 37
1458- )
1459- initial_model = BertModel (config )
1460-
1461- # Push a model on `main`
1462- initial_model .push_to_hub (self .repo_name , token = self .token , safe_serialization = False )
1463-
1464- # Download the model that doesn't have safetensors
1465- BertModel .from_pretrained (self .repo_name , token = self .token )
1466-
1467- for thread in threading .enumerate ():
1468- if thread .name == "Thread-autoconversion" :
1469- thread .join (timeout = 10 )
1470-
1471- with self .subTest ("PR was open with the safetensors account" ):
1472- discussions = self .api .get_repo_discussions (self .repo_name )
1473-
1474- bot_opened_pr = None
1475- bot_opened_pr_title = None
1476-
1477- for discussion in discussions :
1478- if discussion .author == "SFconvertbot" :
1479- bot_opened_pr = True
1480- bot_opened_pr_title = discussion .title
1481-
1482- self .assertTrue (bot_opened_pr )
1483- self .assertEqual (bot_opened_pr_title , "Adding `safetensors` variant of this model" )
1484-
1485- @mock .patch ("transformers.safetensors_conversion.spawn_conversion" )
1486- def test_absence_of_safetensors_triggers_conversion_failed (self , spawn_conversion_mock ):
1487- spawn_conversion_mock .side_effect = HTTPError ()
1488-
1489- config = BertConfig (
1490- vocab_size = 99 , hidden_size = 32 , num_hidden_layers = 5 , num_attention_heads = 4 , intermediate_size = 37
1491- )
1492- initial_model = BertModel (config )
1493-
1494- # Push a model on `main`
1495- initial_model .push_to_hub (self .repo_name , token = self .token , safe_serialization = False )
1496-
1497- # The auto conversion is mocked to always raise; ensure that it doesn't raise in the main thread
1498- BertModel .from_pretrained (self .repo_name , token = self .token )
1499-
15001454
15011455@require_torch
15021456@is_staging_test
0 commit comments