@@ -413,36 +413,71 @@ def get_file_by_hash_function(task_id: str, file_hash: str) -> tuple[bytes, str]
413413 Retrieve a separated audio file by its hash identifier.
414414 Returns tuple of (file_data, actual_filename)
415415 """
416+ print (f"🔍 get_file_by_hash_function called - Task ID: { task_id } , File hash: { file_hash } " )
417+
418+ # Reload the volume to ensure we see the latest files written by other function executions
419+ print (f"🔍 Reloading volume to see latest files..." )
420+ volume .reload ()
421+
416422 # Access Modal Dict to get the job status with file hash mappings
417423 job_status = modal .Dict .from_name ("audio-separator-job-status" , create_if_missing = True )
418424
419425 if task_id not in job_status :
426+ print (f"❌ Task not found in job_status: { task_id } " )
420427 raise FileNotFoundError (f"Task not found: { task_id } " )
421428
422429 status_data = job_status [task_id ]
423430 files_dict = status_data .get ("files" , {})
431+ print (f"🔍 Retrieved files_dict: { files_dict } " )
432+ print (f"🔍 files_dict type: { type (files_dict )} " )
424433
425434 # Check if files is still a list (backward compatibility)
426435 if isinstance (files_dict , list ):
436+ print (f"🔍 Using legacy list format with { len (files_dict )} files" )
427437 # For backward compatibility, try to find file by regenerating hash
428438 for filename in files_dict :
429- if generate_file_hash (filename ) == file_hash :
439+ generated_hash = generate_file_hash (filename )
440+ print (f"🔍 Checking filename '{ filename } ' -> hash '{ generated_hash } ' vs requested '{ file_hash } '" )
441+ if generated_hash == file_hash :
430442 file_path = f"/storage/outputs/{ task_id } /{ filename } "
443+ print (f"🔍 Hash match! Checking file path: { file_path } " )
431444 if os .path .exists (file_path ):
445+ print (f"✅ File exists, returning content" )
432446 with open (file_path , "rb" ) as f :
433447 return f .read (), filename
448+ else :
449+ print (f"❌ File does not exist at path: { file_path } " )
434450 raise FileNotFoundError (f"File with hash { file_hash } not found in legacy format" )
435451
436452 # Normal case: files is a dictionary mapping hashes to filenames
453+ print (f"🔍 Using new hash format with { len (files_dict )} files" )
454+ print (f"🔍 Available hashes: { list (files_dict .keys ())} " )
455+
437456 if file_hash not in files_dict :
457+ print (f"❌ Hash { file_hash } not found in files_dict" )
438458 raise FileNotFoundError (f"File with hash { file_hash } not found" )
439459
440460 actual_filename = files_dict [file_hash ]
441461 file_path = f"/storage/outputs/{ task_id } /{ actual_filename } "
462+ print (f"🔍 Hash found! Filename: '{ actual_filename } '" )
463+ print (f"🔍 Checking file path: { file_path } " )
442464
443465 if not os .path .exists (file_path ):
466+ print (f"❌ File does not exist at path: { file_path } " )
467+ # List what files actually exist in the directory
468+ task_dir = f"/storage/outputs/{ task_id } "
469+ if os .path .exists (task_dir ):
470+ actual_files = os .listdir (task_dir )
471+ print (f"🔍 Files actually in directory ({ len (actual_files )} ):" )
472+ for i , actual_file in enumerate (actual_files ):
473+ print (f" [{ i } ] '{ actual_file } '" )
474+ if actual_file == actual_filename :
475+ print (f" ✅ EXACT MATCH found!" )
476+ else :
477+ print (f"❌ Task directory does not exist: { task_dir } " )
444478 raise FileNotFoundError (f"File not found: { actual_filename } " )
445479
480+ print (f"✅ File exists, returning content" )
446481 with open (file_path , "rb" ) as f :
447482 return f .read (), actual_filename
448483
0 commit comments