Skip to content

Commit

Permalink
Remove old delete from SSv0
Browse files Browse the repository at this point in the history
  • Loading branch information
khl02007 committed Jan 7, 2024
1 parent d607d92 commit ced22a7
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/spyglass/spikesorting/spikesorting_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,49 +240,6 @@ def make(self, key: dict):
sorting = sorting.save(folder=key["sorting_path"])
self.insert1(key)

def delete(self):
"""Extends the delete method of base class to implement permission
checking. Note that this is NOT a security feature, as anyone that has
access to source code can disable it; it just makes it less likely to
accidentally delete entries."""

current_user_name = dj.config["database.user"]
entries = self.fetch()
permission_bool = np.zeros((len(entries),))
logger.info(
f"Attempting to delete {len(entries)} entries, checking permission..."
)

for entry_idx in range(len(entries)):
# check the team name for the entry, then look up the members in that team,
# then get their datajoint user names
team_name = (
SpikeSortingRecordingSelection
& (SpikeSortingRecordingSelection & entries[entry_idx]).proj()
).fetch1()["team_name"]
lab_member_name_list = (
LabTeam.LabTeamMember & {"team_name": team_name}
).fetch("lab_member_name")
datajoint_user_names = []
for lab_member_name in lab_member_name_list:
datajoint_user_names.append(
(
LabMember.LabMemberInfo
& {"lab_member_name": lab_member_name}
).fetch1("datajoint_user_name")
)
permission_bool[entry_idx] = (
current_user_name in datajoint_user_names
)
if np.sum(permission_bool) == len(entries):
logger.info("Permission to delete all specified entries granted.")
super().delete()
else:
raise Exception(
"You do not have permission to delete all specified"
"entries. Not deleting anything."
)

def fetch_nwb(self, *attrs, **kwargs):
raise NotImplementedError
return None
Expand Down

0 comments on commit ced22a7

Please sign in to comment.