Skip to content

Commit

Permalink
fix remove records bug #93
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Oct 17, 2023
1 parent d5baf70 commit 362c745
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pipestat/backends/filebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,23 @@ def remove(
record_identifier=record_identifier,
rm_record=rm_record,
)
# Check if the last remaining attributes are the timestamps
remaining_attributes = list(
self._data[self.pipeline_name][self.pipeline_type][record_identifier].keys()
)
if (
len(remaining_attributes) == 2
and CREATED_TIME in remaining_attributes
and MODIFIED_TIME in remaining_attributes
):
_LOGGER.info(
f"Last result removed for '{record_identifier}'. " f"Removing the record"
)
rm_record = True
self.remove_record(
record_identifier=record_identifier,
rm_record=rm_record,
)
with self._data as locked_data:
locked_data.write()
return True
Expand Down
1 change: 0 additions & 1 deletion tests/test_pipestat.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_basics(
assert status == "running"
assert val_name in psm.retrieve(record_identifier=rec_id)
psm.remove(record_identifier=rec_id, result_identifier=val_name)
#psm.remove(record_identifier=rec_id)
if backend == "file":
psm.clear_status(record_identifier=rec_id)
status = psm.get_status(record_identifier=rec_id)
Expand Down

0 comments on commit 362c745

Please sign in to comment.