Skip to content

Commit

Permalink
Update changelog/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Jan 29, 2024
1 parent 24fa6ba commit 170fb1e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
- Clean up following pre-commit checks. #688
- Add Mixin class to centralize `fetch_nwb` functionality. #692, #734
- Refactor restriction use in `delete_downstream_merge` #703
- Add `cautious_delete` to Mixin class, initial implementation. #711, #762
- Add `cautious_delete` to Mixin class
- Initial implementation. #711, #762
- More robust caching of join to downstream tables. #806
- Add `deprecation_factory` to facilitate table migration. #717
- Add Spyglass logger. #730
- IntervalList: Add secondary key `pipeline` #742
- Increase pytest coverage for `common`, `lfp`, and `utils`. #743
- Update docs to reflect new notebooks. #776
- Add overview of Spyglass to docs. #779
- LFPV1: Fix error for multiple lfp settings on same data #775


### Pipelines

- Spike sorting: Add SpikeSorting V1 pipeline. #651
- LFP: Minor fixes to LFPBandV1 populator and `make`. #706, #795
- LFP:
- Minor fixes to LFPBandV1 populator and `make`. #706, #795
- LFPV1: Fix error for multiple lfp settings on same data #775
- Linearization:
- Minor fixes to LinearizedPositionV1 pipeline #695
- Rename `position_linearization` -> `linearization`. #717
Expand Down
13 changes: 11 additions & 2 deletions docs/src/misc/merge_tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ deleting a part entry before the master. To circumvent this, you can add
`force_parts=True` to the
[`delete` function](https://datajoint.com/docs/core/datajoint-python/0.14/api/datajoint/__init__/#datajoint.table.Table.delete)
call, but this will leave and orphaned primary key in the master. Instead, use
`spyglass.utils.dj_merge_tables.delete_downstream_merge` to delete master/part
pairs.
`(YourTable & restriction).delete_downstream_merge()` to delete master/part
pairs. If errors persist, identify and import the offending part table and
rerun `delete_downstream_merge` with `reload_cache=True`. This process will
be faster for subsequent calls if you reassign the your table after importing.

```python
from spyglass.common import Nwbfile
nwbfile = Nwbfile()
(nwbfile & "nwb_file_name LIKE 'Name%'").delete_downstream_merge()
```


## What

Expand Down
28 changes: 14 additions & 14 deletions src/spyglass/utils/dj_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ def _usage_table(self):
self._usage_table_cache = CautiousDelete
return self._usage_table_cache

def _log_use(self, start, merge_deletes=None):
"""Log use of cautious_delete."""
self._usage_table.insert1(
dict(
duration=time() - start,
dj_user=dj.config["database.user"],
origin=self.full_table_name,
restriction=self.restriction,
merge_deletes=merge_deletes,
)
)

# Rename to `delete` when we're ready to use it
# TODO: Intercept datajoint delete confirmation prompt for merge deletes
def cautious_delete(self, force_permission: bool = False, *args, **kwargs):
Expand All @@ -410,11 +422,6 @@ def cautious_delete(self, force_permission: bool = False, *args, **kwargs):
Passed to datajoint.table.Table.delete.
"""
start = time()
usage_dict = dict(
dj_user=dj.config["database.user"],
origin=self.full_table_name,
restriction=self.restriction,
)

if not force_permission:
self._check_delete_permission()
Expand Down Expand Up @@ -443,19 +450,12 @@ def cautious_delete(self, force_permission: bool = False, *args, **kwargs):
self._commit_merge_deletes(merge_deletes, **kwargs)
else:
logger.info("Delete aborted.")
self._usage_table.insert1(
dict(duration=time() - start, **usage_dict)
)
self._log_use(start)
return

super().delete(*args, **kwargs) # Additional confirm here

self._usage_table.insert1(
dict(
duration=time() - start,
merge_deletes=merge_deletes,
)
)
self._log_use(start=start, merge_deletes=merge_deletes)

def cdel(self, *args, **kwargs):
"""Alias for cautious_delete."""
Expand Down

0 comments on commit 170fb1e

Please sign in to comment.