diff --git a/CHANGELOG.md b/CHANGELOG.md index a047e53b2..121faaf6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop() `open-cv` #1168 - `VideoMaker` class to process frames in multithreaded batches #1168, #1174 - `TrodesPosVideo` updates for `matplotlib` processor #1174 + - User prompt if ambiguous insert in `DLCModelSource` #1192 - Spike Sorting diff --git a/src/spyglass/position/v1/position_dlc_model.py b/src/spyglass/position/v1/position_dlc_model.py index 2a64c05c4..78325b306 100644 --- a/src/spyglass/position/v1/position_dlc_model.py +++ b/src/spyglass/position/v1/position_dlc_model.py @@ -98,16 +98,24 @@ def insert_entry( dj.conn(), full_table_name=part_table.parents()[-1] ) & {"project_name": project_name} - if cls._test_mode: # temporary fix for #1105 - project_path = table_query.fetch(limit=1)[0] - else: - project_path = table_query.fetch1("project_path") + n_found = len(table_query) + if n_found != 1: + logger.warning( + f"Found {len(table_query)} entries found for project " + + f"{project_name}:\n{table_query}" + ) + + choice = "y" + if n_found > 1 and not cls._test_mode: + choice = dj.utils.user_choice("Use first entry?")[0] + if n_found == 0 or choice != "y": + return part_table.insert1( { "dlc_model_name": dlc_model_name, "project_name": project_name, - "project_path": project_path, + "project_path": table_query.fetch("project_path", limit=1)[0], **key, }, **kwargs, diff --git a/src/spyglass/position/v1/position_dlc_project.py b/src/spyglass/position/v1/position_dlc_project.py index 2f19b1664..86617a526 100644 --- a/src/spyglass/position/v1/position_dlc_project.py +++ b/src/spyglass/position/v1/position_dlc_project.py @@ -57,8 +57,6 @@ class DLCProject(SpyglassMixin, dj.Manual): With ability to edit config, extract frames, label frames """ - # Add more parameters as secondary keys... - # TODO: collapse params into blob dict definition = """ project_name : varchar(100) # name of DLC project ---