File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4465,10 +4465,9 @@ def _push_parquet_shards_to_hub_single(
44654465 features = shard .features ,
44664466 )
44674467 shard_path_in_repo = f"{ data_dir } /{ split } -{ index :05d} -of-{ num_shards :05d} .parquet"
4468- tmp_file = tempfile .NamedTemporaryFile (suffix = ".parquet" , delete = False )
4469- try :
4468+ with tempfile .NamedTemporaryFile (suffix = ".parquet" ) as tmp_file :
44704469 shard .to_parquet (tmp_file )
4471- tmp_file .close ()
4470+ tmp_file .flush ()
44724471 parquet_metadata = pq .read_metadata (tmp_file .name )
44734472 num_examples += parquet_metadata .num_rows
44744473 dataset_nbytes += sum (
@@ -4482,12 +4481,6 @@ def _push_parquet_shards_to_hub_single(
44824481 revision = revision ,
44834482 create_pr = create_pr ,
44844483 )
4485- except (Exception , KeyboardInterrupt ):
4486- tmp_file .close ()
4487- Path (tmp_file .name ).unlink ()
4488- raise
4489- tmp_file .close ()
4490- Path (tmp_file .name ).unlink ()
44914484 additions .append (shard_addition )
44924485 yield job_id , False , 1
44934486
You can’t perform that action at this time.
0 commit comments