@@ -104,13 +104,22 @@ def _index_results(self, path: FsPath, silent: bool = False) -> pd.DataFrame:
104104 job_name = parts [2 ]
105105 wu_name = bin_file .name .replace (".bin" , "" )
106106 # append to the DataFrame
107- new_row = pd .DataFrame ([{
108- "user" : user ,
109- "study_name" : study_name ,
110- "job_name" : job_name ,
111- "wu_name" : wu_name ,
112- "bin_file" : bin_file ,
113- }])
107+ new_row = pd .DataFrame (
108+ [
109+ {
110+ "user" : user ,
111+ "study_name" : study_name ,
112+ "job_name" : job_name ,
113+ "wu_name" : wu_name ,
114+ "bin_file" : bin_file ,
115+ "json_file" : bin_file .with_name (
116+ bin_file .name .replace (
117+ "__file_xboinc_state_out.bin" , ".json"
118+ )
119+ ),
120+ }
121+ ]
122+ )
114123 df = pd .concat ([df , new_row ], ignore_index = True )
115124 return df
116125
@@ -299,8 +308,8 @@ def iterate_results(self, study_name):
299308
300309 Yields
301310 ------
302- tuple of (str, xpart.Particles)
303- Job name and corresponding particles object for each result
311+ tuple of (str, dict, xpart.Particles)
312+ Job name, corresponding metadata, and particles object for each result
304313
305314 Raises
306315 ------
@@ -324,6 +333,7 @@ def iterate_results(self, study_name):
324333 for row in self ._df [self ._df ["study_name" ] == study_name ].itertuples ():
325334 job_name = row .job_name
326335 bin_file = row .bin_file
336+ json_file = row .json_file
327337 result = XbState .from_binary (bin_file , raise_version_error = False )
328338 if result is None :
329339 warn (
@@ -332,7 +342,22 @@ def iterate_results(self, study_name):
332342 UserWarning ,
333343 )
334344 continue
335- yield job_name , result .particles
345+ try :
346+ with open (json_file , "r" ) as f :
347+ metadata = json .load (f )
348+ # is metadata an empty dict?
349+ if not metadata :
350+ warn (
351+ f"Warning: The JSON file { json_file } is empty." ,
352+ UserWarning ,
353+ )
354+ except FileNotFoundError :
355+ warn (
356+ f"Warning: The JSON file { json_file } was not found." ,
357+ UserWarning ,
358+ )
359+ metadata = {}
360+ yield job_name , metadata , result .particles
336361
337362 def clean (self , study_name ):
338363 """
@@ -362,6 +387,9 @@ def clean(self, study_name):
362387 bin_file = row .bin_file
363388 if bin_file .exists ():
364389 bin_file .unlink ()
390+ json_file = row .json_file
391+ if json_file .exists ():
392+ json_file .unlink ()
365393 # Remove empty directories
366394 for folder in self ._directory .glob ("*/" ):
367395 if not any (folder .iterdir ()):
@@ -487,4 +515,4 @@ def study_list(cls, user, dev_server=False, silent=False):
487515 >>> print(studies)
488516 """
489517 instance = cls (user , dev_server = dev_server , silent = silent )
490- return instance .get_study_list ()
518+ return instance .get_study_list ()
0 commit comments