@@ -896,12 +896,20 @@ def write_header(self):
896
896
897
897
def load_partition_summaries (self ):
898
898
summaries = []
899
+ not_found = []
899
900
for j in range (self .num_partitions ):
900
- with open (self .path / f"partition_{ j } _metadata.json" ) as f :
901
- summary = json .load (f )
902
- for k , v in summary ['field_summaries' ].items ():
903
- summary ['field_summaries' ][k ] = VcfFieldSummary (** v )
904
- summaries .append (summary )
901
+ try :
902
+ with open (self .path / f"partition_{ j } _metadata.json" ) as f :
903
+ summary = json .load (f )
904
+ for k , v in summary ['field_summaries' ].items ():
905
+ summary ['field_summaries' ][k ] = VcfFieldSummary (** v )
906
+ summaries .append (summary )
907
+ except FileNotFoundError :
908
+ not_found .append (j )
909
+ if not_found :
910
+ raise FileNotFoundError (
911
+ f"Partition metadata not found for { len (not_found )} partitions: { not_found } "
912
+ )
905
913
return summaries
906
914
907
915
@@ -1008,8 +1016,13 @@ def convert_slice(self, start, stop, *, worker_processes=1, show_progress=False,
1008
1016
f"Exploding { self .num_columns } columns { self .metadata .num_records } variants "
1009
1017
f"{ self .num_samples } samples"
1010
1018
)
1019
+ if start < 0 :
1020
+ raise ValueError (f"start={ start } must be non-negative" )
1021
+ if stop > self .num_partitions :
1022
+ raise ValueError (f"stop={ stop } must be less than the number of partitions" )
1023
+ num_records_to_progress = sum ([partition .num_records for partition in self .metadata .partitions [start :stop ]])
1011
1024
progress_config = core .ProgressConfig (
1012
- total = self . metadata . num_records ,
1025
+ total = num_records_to_progress ,
1013
1026
units = "vars" ,
1014
1027
title = "Explode" ,
1015
1028
show = show_progress ,
0 commit comments