@@ -351,6 +351,8 @@ def download_files(
351351 attributes : None | str | Sequence [str ],
352352 destination : Path ,
353353 ) -> Generator [pa .RecordBatch , None , None ]:
354+ destination = destination .resolve ()
355+
354356 # Get list of file attributes to batch
355357 file_attributes = nq_runs .list_attributes (
356358 project = project_id ,
@@ -389,7 +391,11 @@ def fetch_and_convert_file_batch(batch_attributes):
389391
390392 # Convert to schema
391393 converted_df = self ._convert_files_to_schema (
392- file_paths_df , project_id , "file" , None
394+ downloaded_files_df = file_paths_df ,
395+ project_id = project_id ,
396+ attribute_type = "file" ,
397+ file_series_df = None ,
398+ destination = destination ,
393399 )
394400
395401 return pa .RecordBatch .from_pandas (converted_df , schema = model .SCHEMA )
@@ -420,7 +426,11 @@ def fetch_and_convert_file_series_batch(batch_attributes):
420426
421427 # Convert to schema
422428 converted_df = self ._convert_files_to_schema (
423- file_series_paths_df , project_id , "file_series" , files_series_df
429+ downloaded_files_df = file_series_paths_df ,
430+ project_id = project_id ,
431+ attribute_type = "file_series" ,
432+ file_series_df = files_series_df ,
433+ destination = destination ,
424434 )
425435
426436 return pa .RecordBatch .from_pandas (converted_df , schema = model .SCHEMA )
@@ -467,6 +477,7 @@ def _convert_files_to_schema(
467477 project_id : str ,
468478 attribute_type : Literal ["file" , "file_series" ],
469479 file_series_df : Optional [pd .DataFrame ],
480+ destination : Path ,
470481 ) -> pd .DataFrame :
471482 """Convert downloaded files DataFrame to long format matching model.SCHEMA."""
472483 # Reset index to make 'run' a column
@@ -511,7 +522,9 @@ def _convert_files_to_schema(
511522 "datetime_value" : None ,
512523 "string_set_value" : None ,
513524 "file_value" : melted_df ["file_path" ].map (
514- lambda x : {"path" : x } if pd .notna (x ) else None
525+ lambda x : {"path" : str (Path (x ).relative_to (destination ))}
526+ if pd .notna (x )
527+ else None
515528 ),
516529 "histogram_value" : None ,
517530 }
0 commit comments