@@ -220,7 +220,13 @@ def write_session(self, subject:Subject, session:Session, on_conflict=OnConflict
220220 self .logger .info (f"Added session with ID { session_id } for subject { subject .id } to the database." )
221221
222222 def delete_session (self , subject_id : str , session_id : str , on_conflict : OnConflictOpts = OnConflictOpts .ERROR ):
223+ """Delete a session and its associated data from the database.
223224
225+ Args:
226+ subject_id: ID of the subject the session belongs to
227+ session_id: ID of the session to delete
228+ on_conflict: Behavior when session doesn't exist ('error' or 'skip')
229+ """
224230 # Check if the session ID exists in the database for this subject
225231 session_ids = self .get_session_ids (subject_id )
226232
@@ -235,14 +241,13 @@ def delete_session(self, subject_id: str, session_id: str, on_conflict: OnConfli
235241
236242 # Delete the session file
237243 session_filename = self .get_session_filename (subject_id , session_id )
238- if Path . is_file ( session_filename ):
244+ if session_filename . parent . is_dir ( ):
239245 shutil .rmtree (session_filename .parent )
240246
241- if session_id in session_ids :
242- session_ids .remove (session_id )
243- self .write_session_ids (subject_id , session_ids )
247+ session_ids .remove (session_id )
248+ self .write_session_ids (subject_id , session_ids )
244249
245- self .logger .info (f"Removed Session with ID { session_id } from the database." )
250+ self .logger .info (f"Removed session with ID { session_id } from the database." )
246251
247252 def write_run (self , run :Run , session :Session = None , protocol :Protocol = None , on_conflict = OnConflictOpts .ERROR ):
248253 """Write a run with a snapshot of session and a snapshot of protocol if provided
0 commit comments