@@ -304,13 +304,13 @@ def save_task_status(task_id, task_type, status=TASK_STATUS_PENDING, parent_task
304304 END
305305 """ , (task_id , parent_task_id , task_type , sub_type_identifier , status , progress , details_json , current_unix_time , status , current_unix_time , current_unix_time , current_unix_time ))
306306 db .commit ()
307- except psycopg2 .Error as e :
308- logger .error (f"DB Error saving task status for { task_id } : { e } " )
307+ except psycopg2 .Error :
308+ logger .exception (f"DB Error saving task status for { task_id } " )
309309 try :
310310 db .rollback ()
311311 logger .info (f"DB transaction rolled back for task status update of { task_id } ." )
312- except psycopg2 .Error as rb_e :
313- logger .error (f"DB Error during rollback for task status { task_id } : { rb_e } " )
312+ except psycopg2 .Error :
313+ logger .exception (f"DB Error during rollback for task status { task_id } " )
314314 finally :
315315 cur .close ()
316316
@@ -394,8 +394,8 @@ def get_score_data_by_ids(item_ids_list):
394394 try :
395395 cur .execute (query , (tuple (item_ids_list ),))
396396 rows = cur .fetchall ()
397- except Exception as e :
398- logger .error ( f "Error fetching score data by IDs: { e } " )
397+ except Exception :
398+ logger .exception ( "Error fetching score data by IDs" )
399399 rows = []
400400 finally :
401401 cur .close ()
@@ -491,8 +491,8 @@ def load_map_projection(index_name, force_reload=False):
491491 MAP_PROJECTION_CACHE = {'index_name' : index_name , 'id_map' : id_map , 'projection' : proj }
492492 logger .info (f"Map projection '{ index_name } ' with { len (id_map )} items loaded successfully into memory." )
493493 return id_map , proj
494- except Exception as e :
495- logger .error ( f "Failed to load map projection: { e } " , exc_info = True )
494+ except Exception :
495+ logger .exception ( "Failed to load map projection" )
496496 return None , None
497497 finally :
498498 cur .close ()
@@ -611,9 +611,9 @@ def _parse_year_from_date(year_value):
611611 """ , (item_id , psycopg2 .Binary (embedding_blob )))
612612
613613 conn .commit ()
614- except Exception as e :
614+ except Exception :
615615 conn .rollback ()
616- logger .error ("Error saving track analysis and embedding for %s: %s " , item_id , e )
616+ logger .exception ("Error saving track analysis and embedding for %s" , item_id )
617617 raise
618618 finally :
619619 cur .close ()
@@ -633,9 +633,9 @@ def save_clap_embedding(item_id, clap_embedding_vector):
633633 ON CONFLICT (item_id) DO UPDATE SET embedding = EXCLUDED.embedding
634634 """ , (item_id , psycopg2 .Binary (embedding_blob )))
635635 conn .commit ()
636- except Exception as e :
636+ except Exception :
637637 conn .rollback ()
638- logger .error (f"Error saving CLAP embedding for { item_id } : { e } " )
638+ logger .exception (f"Error saving CLAP embedding for { item_id } " )
639639 raise
640640 finally :
641641 cur .close ()
@@ -655,8 +655,8 @@ def get_clap_embedding(item_id):
655655 if row and row [0 ]:
656656 return np .frombuffer (row [0 ], dtype = np .float32 )
657657 return None
658- except Exception as e :
659- logger .error (f"Error loading CLAP embedding for { item_id } : { e } " )
658+ except Exception :
659+ logger .exception (f"Error loading CLAP embedding for { item_id } " )
660660 return None
661661 finally :
662662 cur .close ()
@@ -686,9 +686,9 @@ def save_lyrics_embedding(item_id, lyrics_embedding_vector, axis_vector=None):
686686 """ , (item_id , psycopg2 .Binary (embedding_blob ),
687687 psycopg2 .Binary (axis_blob ) if axis_blob is not None else None ))
688688 conn .commit ()
689- except Exception as e :
689+ except Exception :
690690 conn .rollback ()
691- logger .error (f"Error saving lyrics embedding for { item_id } : { e } " )
691+ logger .exception (f"Error saving lyrics embedding for { item_id } " )
692692 raise
693693 finally :
694694 cur .close ()
@@ -1121,9 +1121,9 @@ def clean_up_previous_main_tasks():
11211121 logger .info (f"Archived { archived_count } previous main tasks and deleted { deleted_children_count } child tasks." )
11221122 else :
11231123 logger .info ("No previous main tasks found to clean up." )
1124- except Exception as e_main_clean :
1124+ except Exception :
11251125 db .rollback ()
1126- logger .error ( f "Error during the main task cleanup process: { e_main_clean } " )
1126+ logger .exception ( "Error during the main task cleanup process" )
11271127 finally :
11281128 cur .close ()
11291129
@@ -1192,9 +1192,9 @@ def save_alchemy_anchor(name, centroid):
11921192 row = cur .fetchone ()
11931193 conn .commit ()
11941194 return dict (row ) if row else None
1195- except Exception as e :
1195+ except Exception :
11961196 conn .rollback ()
1197- logger .error (f"Failed to save alchemy anchor '{ name } ': { e } " )
1197+ logger .exception (f"Failed to save alchemy anchor '{ name } '" )
11981198 return None
11991199 finally :
12001200 cur .close ()
@@ -1206,8 +1206,8 @@ def get_alchemy_anchors():
12061206 cur .execute ("SELECT id, name, created_at FROM alchemy_anchors ORDER BY created_at DESC" )
12071207 rows = cur .fetchall ()
12081208 return [dict (row ) for row in rows ]
1209- except Exception as e :
1210- logger .error ( f "Failed to load alchemy anchors: { e } " )
1209+ except Exception :
1210+ logger .exception ( "Failed to load alchemy anchors" )
12111211 return []
12121212 finally :
12131213 cur .close ()
@@ -1219,9 +1219,9 @@ def delete_alchemy_anchor(anchor_id):
12191219 cur .execute ("DELETE FROM alchemy_anchors WHERE id = %s" , (anchor_id ,))
12201220 conn .commit ()
12211221 return cur .rowcount > 0
1222- except Exception as e :
1222+ except Exception :
12231223 conn .rollback ()
1224- logger .error (f"Failed to delete alchemy anchor id={ anchor_id } : { e } " )
1224+ logger .exception (f"Failed to delete alchemy anchor id={ anchor_id } " )
12251225 return False
12261226 finally :
12271227 cur .close ()
@@ -1241,8 +1241,8 @@ def get_alchemy_anchor_by_id(anchor_id):
12411241 except Exception :
12421242 anchor ['centroid' ] = None
12431243 return anchor
1244- except Exception as e :
1245- logger .error (f"Failed to fetch alchemy anchor id={ anchor_id } : { e } " )
1244+ except Exception :
1245+ logger .exception (f"Failed to fetch alchemy anchor id={ anchor_id } " )
12461246 return None
12471247 finally :
12481248 cur .close ()
@@ -1262,9 +1262,9 @@ def update_alchemy_anchor_name(anchor_id, name):
12621262 if not row :
12631263 return None
12641264 return dict (row )
1265- except Exception as e :
1265+ except Exception :
12661266 conn .rollback ()
1267- logger .error (f"Failed to rename alchemy anchor id={ anchor_id } : { e } " )
1267+ logger .exception (f"Failed to rename alchemy anchor id={ anchor_id } " )
12681268 return None
12691269 finally :
12701270 cur .close ()
@@ -1379,9 +1379,9 @@ def save_map_projection(index_name, id_map, projection_array):
13791379 logger .info (f"Saved map projection '{ index_name } ' to DB: { len (blob )} bytes, ids={ id_count } " )
13801380 except Exception :
13811381 logger .debug ("Saved map projection but failed to compute size/id_count for log." )
1382- except Exception as e :
1382+ except Exception :
13831383 conn .rollback ()
1384- logger .error ( f "Failed to save map projection: { e } " )
1384+ logger .exception ( "Failed to save map projection" )
13851385 raise
13861386
13871387def load_artist_projection (index_name = 'artist_map' , force_reload = False ):
@@ -1413,8 +1413,8 @@ def load_artist_projection(index_name='artist_map', force_reload=False):
14131413 ARTIST_PROJECTION_CACHE = {'index_name' : index_name , 'component_map' : component_map , 'projection' : proj }
14141414 logger .info (f"Artist projection '{ index_name } ' with { len (component_map )} components loaded successfully into memory." )
14151415 return component_map , proj
1416- except Exception as e :
1417- logger .error ( f "Failed to load artist projection: { e } " , exc_info = True )
1416+ except Exception :
1417+ logger .exception ( "Failed to load artist projection" )
14181418 return None , None
14191419 finally :
14201420 cur .close ()
@@ -1432,9 +1432,9 @@ def save_artist_projection(index_name, component_map, projections):
14321432 cur .execute ("INSERT INTO artist_component_projection (index_name, projection_data, artist_component_map_json) VALUES (%s, %s, %s) ON CONFLICT (index_name) DO UPDATE SET projection_data = EXCLUDED.projection_data, artist_component_map_json = EXCLUDED.artist_component_map_json, created_at = CURRENT_TIMESTAMP" , (index_name , proj_blob , component_map_json ))
14331433 conn .commit ()
14341434 logger .info (f"Saved artist projection '{ index_name } ' with { len (component_map )} components to database." )
1435- except Exception as e :
1435+ except Exception :
14361436 conn .rollback ()
1437- logger .error ( f "Failed to save artist projection: { e } " , exc_info = True )
1437+ logger .exception ( "Failed to save artist projection" )
14381438 finally :
14391439 cur .close ()
14401440
@@ -1454,8 +1454,8 @@ def update_playlist_table(playlists): # Removed db_path
14541454 for item_id , title , author in cluster :
14551455 cur .execute ("INSERT INTO playlist (playlist_name, item_id, title, author) VALUES (%s, %s, %s, %s) ON CONFLICT (playlist_name, item_id) DO NOTHING" , (name , item_id , title , author ))
14561456 conn .commit ()
1457- except Exception as e :
1457+ except Exception :
14581458 conn .rollback ()
1459- logger .error ("Error updating playlist table: %s" , e )
1459+ logger .exception ("Error updating playlist table" )
14601460 finally :
14611461 cur .close ()
0 commit comments