Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure merge tables declared in new database #1205

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Change Log

## [0.5.5] (TBD)

## [0.5.5] (Unreleased)

### Infrastructure

- Ensure merge tables are declared during file insertion #1205
- Update URL for DANDI Docs #1210

## [0.5.4] (December 20, 2024)
Expand Down
3 changes: 3 additions & 0 deletions src/spyglass/common/populate_all_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from spyglass.common.common_task import TaskEpoch
from spyglass.common.common_usage import InsertError
from spyglass.utils import logger
from spyglass.utils.dj_helper_fn import declare_all_merge_tables


def log_insert_error(
Expand Down Expand Up @@ -117,6 +118,8 @@ def populate_all_common(
"""
from spyglass.spikesorting.imported import ImportedSpikeSorting

declare_all_merge_tables()

error_constants = dict(
dj_user=dj.config["database.user"],
connection_id=dj.conn().connection_id,
Expand Down
14 changes: 14 additions & 0 deletions src/spyglass/utils/dj_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ def ensure_names(
return getattr(table, "full_table_name", None)


def declare_all_merge_tables():
"""Ensures all merge tables in the spyglass core package are declared.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Ensures all merge tables in the spyglass core package are declared.
"""Ensures all merge tables in the spyglass core package are declared.

- Prevents circular imports
- Prevents errors from table declaration within a transaction
- Run during nwb insertion
"""
from spyglass.decoding.decoding_merge import DecodingOutput # noqa: F401
from spyglass.lfp.lfp_merge import LFPOutput # noqa: F401
from spyglass.position.position_merge import PositionOutput # noqa: F401
from spyglass.spikesorting.spikesorting_merge import ( # noqa: F401
SpikeSortingOutput,
)


def fuzzy_get(index: Union[int, str], names: List[str], sources: List[str]):
"""Given lists of items/names, return item at index or by substring."""
if isinstance(index, int):
Expand Down
Loading