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