Skip to content

Commit

Permalink
Partial solve of LorenFrankLab#886 - Ask import
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Mar 29, 2024
1 parent b9b8963 commit 4c37ba6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/spyglass/utils/dj_merge_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def is_merge_table(table):
"""Return True if table definition matches the default Merge table."""
this_def = re.sub( # First remove comments, then blank lines
r"\n\s*\n", "\n", re.sub(r"#.*\n", "\n", table.definition)
r"\n\s*\n", "\n", re.sub(r"#.*\n", "\n", str(table.heading))
)
return this_def == MERGE_DEFINITION

Expand Down
7 changes: 6 additions & 1 deletion src/spyglass/utils/dj_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from datajoint.logging import logger as dj_logger
from datajoint.table import Table
from datajoint.utils import get_master, user_choice
from networkx import NetworkXError
from pymysql.err import DataError

from spyglass.utils.database_settings import SHARED_MODULES
Expand Down Expand Up @@ -150,7 +151,11 @@ def search_descendants(parent):
merge_tables[master_name] = master_ft
search_descendants(master_ft)

_ = search_descendants(self)
try:
_ = search_descendants(self)
except NetworkXError as e:
table_name = "".join(e.args[0].split("`")[1:4])
raise ValueError(f"Please import {table_name} and try again.")

logger.info(
f"Building merge cache for {self.table_name}.\n\t"
Expand Down

0 comments on commit 4c37ba6

Please sign in to comment.