|
6 | 6 | import os |
7 | 7 | import re |
8 | 8 | from pathlib import Path |
9 | | -from typing import Iterable, List, Type, Union |
| 9 | +from typing import Any, Iterable, List, Optional, Type, Union |
10 | 10 | from uuid import uuid4 |
11 | 11 |
|
12 | 12 | import datajoint as dj |
@@ -106,9 +106,9 @@ def declare_all_merge_tables(): |
106 | 106 | from spyglass.decoding.decoding_merge import DecodingOutput # noqa: F401 |
107 | 107 | from spyglass.lfp.lfp_merge import LFPOutput # noqa: F401 |
108 | 108 | from spyglass.position.position_merge import PositionOutput # noqa: F401 |
109 | | - from spyglass.spikesorting.spikesorting_merge import ( # noqa: F401 |
| 109 | + from spyglass.spikesorting.spikesorting_merge import ( |
110 | 110 | SpikeSortingOutput, |
111 | | - ) |
| 111 | + ) # noqa: F401 |
112 | 112 |
|
113 | 113 |
|
114 | 114 | def fuzzy_get(index: Union[int, str], names: List[str], sources: List[str]): |
@@ -686,16 +686,39 @@ def bytes_to_human_readable(size: int) -> str: |
686 | 686 | return msg_template.format(size=size, unit="PB") |
687 | 687 |
|
688 | 688 |
|
689 | | -def accept_divergence(key, new_value, existing_value, test_mode=False): |
690 | | - """prompt to accept divergence in values between existing and new entries""" |
| 689 | +def accept_divergence( |
| 690 | + key: str, |
| 691 | + new_value: Any, |
| 692 | + existing_value: Any, |
| 693 | + test_mode: bool = False, |
| 694 | + table_name: Optional[str] = None, |
| 695 | +): |
| 696 | + """Prompt to accept divergence in values between existing and new entries |
| 697 | +
|
| 698 | + Parameters |
| 699 | + ---------- |
| 700 | + key : str |
| 701 | + Name of the column where the divergence is found |
| 702 | + new_value : Any |
| 703 | + New value to be inserted into the table |
| 704 | + existing_value : Any |
| 705 | + Existing value in the table that is different from the new value |
| 706 | + test_mode : bool, optional |
| 707 | + If True, will not prompt and return False, by default False |
| 708 | + table_name : str, optional |
| 709 | + Name of the table where the divergence is found, by default None |
| 710 | + """ |
691 | 711 | if test_mode: |
692 | 712 | # If get here in test mode, is because want to test failure |
693 | 713 | logger.warning( |
694 | | - "accept_divergence called in test mode, returning False without prompt" |
| 714 | + "accept_divergence called in test mode, returning False w/o prompt" |
695 | 715 | ) |
696 | 716 | return False |
| 717 | + tbl_msg = "" |
| 718 | + if table_name: # optional message with table name |
| 719 | + tbl_msg = f" of '{table_name}'" |
697 | 720 | response = dj.utils.user_choice( |
698 | | - f"Existing entry differs in '{key}' column.\n" |
| 721 | + f"Existing entry differs in '{key}' column{tbl_msg}.\n" |
699 | 722 | + "Accept the existing value of: \n" |
700 | 723 | + f"'{existing_value}' \n" |
701 | 724 | + "in place of the new value: \n" |
|
0 commit comments