Spaces:
Sleeping
Sleeping
Update SQL
Browse files
SQL
CHANGED
|
@@ -1,123 +1,22 @@
|
|
| 1 |
-
|
| 2 |
-
does nothing. And the cache serves stale results regardless.
|
| 3 |
-
|
| 4 |
-
Let me write the plan before implementing.
|
| 5 |
-
β Updated plan
|
| 6 |
-
βΏ /plan to preview
|
| 7 |
-
|
| 8 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Ready to code?
|
| 9 |
-
Here is Claude's plan: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Card Lab β Hitter Selector Diagnostic + Fix (Pass 5)
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
1. pitcher_inning_first_seed_events is too sparse (~30 pitchers) β Mick Abel almost certainly not in it, so pitcher_set is empty for him β no exclusion happens
|
| 15 |
-
2. @st.cache_data(ttl=600) on _cached_hitters serves stale results from pre-fix calls β new code may not have been exercised at all
|
| 16 |
|
| 17 |
-
|
| 18 |
-
happening for Ivan Herrera, Mick Abel, and Jason Adam.
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
β visualization/cards/card_queries.py β Replace _norm_lower with normalize_name_for_compare; add verbose diagnostics to get_card_lab_hitters() β
|
| 27 |
-
βββββββββββββββββββββββββββββββββββββββΌββββββββββββββοΏ½οΏ½ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
| 28 |
-
β visualization/card_lab_page.py β Remove @st.cache_data from _cached_hitters (temporary, diagnostic only) β
|
| 29 |
-
βββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
Change 1 β card_queries.py: Improved normalization helper
|
| 35 |
-
|
| 36 |
-
Replace _norm_lower (lines 65β72) with normalize_name_for_compare. Extra whitespace collapse handles any leading/trailing/double spaces:
|
| 37 |
-
|
| 38 |
-
def normalize_name_for_compare(name: str) -> str:
|
| 39 |
-
"""Normalize 'Last, First' β 'first last' for role-dominance comparison."""
|
| 40 |
-
if not name:
|
| 41 |
-
return ""
|
| 42 |
-
s = str(name).strip()
|
| 43 |
-
if "," in s:
|
| 44 |
-
last, first = [x.strip() for x in s.split(",", 1)]
|
| 45 |
-
s = f"{first} {last}"
|
| 46 |
-
return " ".join(s.lower().split())
|
| 47 |
-
|
| 48 |
-
Update every reference from _norm_lower β normalize_name_for_compare inside get_card_lab_hitters().
|
| 49 |
-
|
| 50 |
-
---
|
| 51 |
-
Change 2 β card_queries.py: Diagnostic logging in get_card_lab_hitters()
|
| 52 |
-
|
| 53 |
-
Add these log lines after building rows and pitcher_set, BEFORE the filter loop:
|
| 54 |
-
|
| 55 |
-
# Diagnostic: raw candidates
|
| 56 |
-
logger.info(
|
| 57 |
-
"[card_lab_hitter_diag] raw_candidates=%s pitcher_set_size=%s",
|
| 58 |
-
len(rows), len(pitcher_set),
|
| 59 |
-
)
|
| 60 |
-
if rows:
|
| 61 |
-
sample = [(r[0], r[1]) for r in rows[:25]]
|
| 62 |
-
logger.info("[card_lab_hitter_diag] first_25_candidates=%s", sample)
|
| 63 |
-
if pitcher_set:
|
| 64 |
-
sample_ps = sorted(pitcher_set)[:25]
|
| 65 |
-
logger.info("[card_lab_hitter_diag] first_25_pitcher_set=%s", sample_ps)
|
| 66 |
-
|
| 67 |
-
# Diagnostic: per-player check for known cases
|
| 68 |
-
_RAW_MAP = {normalize_name_for_compare(r[0]): (r[0], r[1]) for r in rows if r[0]}
|
| 69 |
-
for check_name in ("Ivan Herrera", "Mick Abel", "Jason Adam"):
|
| 70 |
-
norm = normalize_name_for_compare(check_name)
|
| 71 |
-
raw_present = norm in _RAW_MAP
|
| 72 |
-
b_count = _RAW_MAP[norm][1] if raw_present else 0
|
| 73 |
-
in_ps = norm in pitcher_set
|
| 74 |
-
included = raw_present and (b_count >= 20) and (norm not in pitcher_set or b_count >= 100)
|
| 75 |
-
logger.info(
|
| 76 |
-
'[card_lab_hitter_diag] name="%s" raw_present=%s batter_pitch_count=%s '
|
| 77 |
-
'normalized="%s" in_pitcher_set=%s included=%s',
|
| 78 |
-
check_name, raw_present, b_count, norm, in_ps, included,
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
---
|
| 82 |
-
Change 3 β card_lab_page.py: Remove cache from _cached_hitters
|
| 83 |
-
|
| 84 |
-
Change (diagnostic only β will be re-added once classification is confirmed correct):
|
| 85 |
-
|
| 86 |
-
# DIAGNOSTIC: cache disabled β re-add @st.cache_data(ttl=600) once filter is verified
|
| 87 |
-
def _cached_hitters(_conn, year):
|
| 88 |
-
return get_card_lab_hitters(_conn, year=year)
|
| 89 |
-
|
| 90 |
-
_cached_pitchers is unchanged (pitcher selector already works).
|
| 91 |
-
|
| 92 |
-
---
|
| 93 |
-
What is NOT changing
|
| 94 |
-
|
| 95 |
-
- get_card_lab_pitchers() β correct, untouched
|
| 96 |
-
- get_player_card_window_df() β correct, untouched
|
| 97 |
-
- All renderers / chart builders
|
| 98 |
-
- database/db.py
|
| 99 |
-
|
| 100 |
-
---
|
| 101 |
-
Post-deploy verification
|
| 102 |
-
|
| 103 |
-
Check HuggingFace logs for [card_lab_hitter_diag] lines after loading the hitter dropdown.
|
| 104 |
-
|
| 105 |
-
Expected reveals:
|
| 106 |
-
- If raw_candidates is low or Ivan Herrera is absent β threshold or data issue
|
| 107 |
-
- If pitcher_set_size is tiny (0β5) β pitcher_inning_first_seed_events is too sparse for exclusion; need alternative exclusion strategy
|
| 108 |
-
- If Ivan Herrera is raw_present=True but included=False β normalization mismatch or threshold excluding him
|
| 109 |
-
- If Mick Abel is in_pitcher_set=False β exclusion source is wrong; need a different approach for the next fix pass
|
| 110 |
-
|
| 111 |
-
Success criteria (after reading logs and any follow-up fix):
|
| 112 |
-
1. Ivan Herrera appears in 2025 hitter selector
|
| 113 |
-
2. Mick Abel absent
|
| 114 |
-
3. Jason Adam absent
|
| 115 |
-
4. Pitcher selector unchanged
|
| 116 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 117 |
-
|
| 118 |
-
Claude has written up a plan and is ready to execute. Would you like to proceed?
|
| 119 |
-
|
| 120 |
-
β― 1. Yes, clear context (36% used) and auto-accept edits
|
| 121 |
-
2. Yes, auto-accept edits
|
| 122 |
-
3. Yes, manually approve edits
|
| 123 |
-
4. Type here to tell Claude what to change
|
|
|
|
| 1 |
+
Proceed with implementation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
This is the correct next step:
|
| 4 |
+
- temporary diagnostic logging is the right move
|
| 5 |
+
- removing hitter cache is correct
|
| 6 |
+
- keeping pitcher selector untouched is correct
|
| 7 |
+
- normalization hardening is correct
|
| 8 |
|
| 9 |
+
Add one small improvement before executing:
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
After logging the three named checks (Ivan Herrera, Mick Abel, Jason Adam), also log:
|
|
|
|
| 12 |
|
| 13 |
+
1. final filtered hitter count
|
| 14 |
+
2. first 25 FINAL hitter names after filtering
|
| 15 |
|
| 16 |
+
Example:
|
| 17 |
+
logger.info("[card_lab_hitter_diag] final_count=%s", len(filtered))
|
| 18 |
+
logger.info("[card_lab_hitter_diag] first_25_final=%s", filtered[:25])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
That will let us immediately see whether the filter changed the output at all.
|
| 21 |
|
| 22 |
+
Otherwise, proceed exactly as planned.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|