Slaiwala commited on
Commit
06d7379
·
verified ·
1 Parent(s): 30e4636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -5
app.py CHANGED
@@ -4,6 +4,7 @@
4
  # - Clean CPT table (no per-row modifier columns)
5
  # - Case Modifiers panel (-22, -50, -53, -80, -82, ...)
6
  # - Build tag + Core file path shown in UI chips and logged
 
7
  # - Structured logs/export, graceful errors, modern Gradio usage
8
  # ------------------------------------------------------------------------------
9
 
@@ -22,12 +23,38 @@ import gradio as gr
22
  import os as _os, sys as _sys, inspect as _inspect
23
  _sys.path.insert(0, _os.path.abspath(".")) # ensure repo root is first on sys.path
24
 
 
25
  try:
26
- # Preferred package layout
27
- from spine_coder.spine_coder.spine_coder_core import suggest_with_cpt_billing
28
- except ImportError:
29
- # Fallback to flat layout
30
- from spine_coder.spine_coder_core import suggest_with_cpt_billing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # Prove which file is actually loaded (visible in Space logs)
33
  try:
 
4
  # - Clean CPT table (no per-row modifier columns)
5
  # - Case Modifiers panel (-22, -50, -53, -80, -82, ...)
6
  # - Build tag + Core file path shown in UI chips and logged
7
+ # - Force-import + reload of core to avoid stale cache
8
  # - Structured logs/export, graceful errors, modern Gradio usage
9
  # ------------------------------------------------------------------------------
10
 
 
23
  import os as _os, sys as _sys, inspect as _inspect
24
  _sys.path.insert(0, _os.path.abspath(".")) # ensure repo root is first on sys.path
25
 
26
+ # Try normal imports (still useful for local dev)
27
  try:
28
+ from spine_coder.spine_coder.spine_coder_core import suggest_with_cpt_billing as _maybe_suggest
29
+ except Exception:
30
+ try:
31
+ from spine_coder.spine_coder_core import suggest_with_cpt_billing as _maybe_suggest
32
+ except Exception:
33
+ _maybe_suggest = None
34
+
35
+ # --- Force-load the v2.1 core and avoid stale caches (HF Space sometimes caches modules) ---
36
+ import importlib
37
+
38
+ def _force_import_core():
39
+ mod = None
40
+ try:
41
+ # Preferred package layout
42
+ mod = importlib.import_module("spine_coder.spine_coder.spine_coder_core")
43
+ except Exception:
44
+ # Fallback to flat layout
45
+ mod = importlib.import_module("spine_coder.spine_coder_core")
46
+ # Hard reload to bust any stale cache
47
+ mod = importlib.reload(mod)
48
+ return mod
49
+
50
+ try:
51
+ _core = _force_import_core()
52
+ suggest_with_cpt_billing = _core.suggest_with_cpt_billing
53
+ except Exception:
54
+ # Last resort: use whatever we imported earlier (if any)
55
+ if _maybe_suggest is None:
56
+ raise
57
+ suggest_with_cpt_billing = _maybe_suggest
58
 
59
  # Prove which file is actually loaded (visible in Space logs)
60
  try: