Jay1121 commited on
Commit
296365d
Β·
verified Β·
1 Parent(s): 3e1e839

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -33
app.py CHANGED
@@ -43,16 +43,8 @@ GRAPH_CONFIG = {
43
  "showTips": True,
44
  }
45
 
46
- # === [HF ADD] Excel 경둜 μ„€μ • (app.pyμ—μ„œ κΈ°μ‘΄ DEFAULT_PATH 라인 'λ°”λ‘œ μ•„λž˜' μΆ”κ°€) ===
47
- from pathlib import Path
48
-
49
- ROOT = Path(__file__).resolve().parent # /app (Dockerμ—μ„œ μž‘μ—… 디렉토리)
50
- DEFAULT_PATH = os.getenv(
51
- "EXCEL_PATH",
52
- str(ROOT / "bayesian_analysis_total_v1.xlsx") # 리포 λ£¨νŠΈμ— 올린 파일λͺ…
53
- )
54
- EXCEL_PATH = DEFAULT_PATH # μ½”λ“œ μ–΄λ”˜κ°€μ—μ„œ DEFAULT_PATHλ₯Ό 써도 HF에선 이 값이 적용됨
55
-
56
 
57
  # ===================== 레벨 μƒμˆ˜ =====================
58
  LEVEL_OVERALL="전체"; LEVEL_SEGMENT="μ„Έκ·Έλ¨ΌνŠΈ"; LEVEL_MODEL="λͺ¨λΈ"
@@ -2308,7 +2300,6 @@ def standardize_top_fig(fig):
2308
  return fig
2309
 
2310
  # ───────────────── app.layout ꡐ체 ─────────────────
2311
- # ───────────── spacing knobs (ν•œ κ³³μ—μ„œ 쑰절) ─────────────
2312
  ROW_GAP = "16px" # μΉ΄λ“œ 사이 간격
2313
  PAGE_PAD = "24px 28px 24px" # ν–‰ μ•ˆμͺ½ νŒ¨λ”©
2314
  CARD_H = "430px" # μΉ΄λ“œ(λ°•μŠ€) 높이
@@ -2318,7 +2309,6 @@ KPI_GAP = "12px" # KPI μΉ΄λ“œ 간격
2318
  ROW1_COLS = "1fr 1fr 1fr" # 상단 3μΉ΄λ“œ 동일 λ„ˆλΉ„
2319
  ROW2_COLS = "1fr 1fr 1fr" # ν•˜λ‹¨ 3μΉ΄λ“œ 동일 λ„ˆλΉ„
2320
 
2321
- # ───────────────── app.layout ꡐ체 ─────────────────
2322
  app.layout = html.Div(
2323
  [
2324
  dcc.Store(id="store-master"),
@@ -2407,13 +2397,21 @@ app.layout = html.Div(
2407
  html.Div(
2408
  [
2409
  html.Div(
2410
- dcc.Graph(id="fig-sankey", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
2411
- style={**CARD_STYLE, "height": CARD_H}
 
 
 
 
2412
  ),
2413
 
2414
  html.Div(
2415
- dcc.Graph(id="fig-matrix", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
2416
- style={**CARD_STYLE, "height": CARD_H}
 
 
 
 
2417
  ),
2418
 
2419
  html.Div(
@@ -2426,14 +2424,18 @@ app.layout = html.Div(
2426
  ],
2427
  style={"marginBottom":"6px"},
2428
  ),
2429
- dcc.Graph(id="fig-right", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
 
 
 
 
2430
  ],
2431
- style={**CARD_STYLE, "height": CARD_H},
2432
  ),
2433
  ],
2434
  style={
2435
  "display":"grid",
2436
- "gridTemplateColumns": ROW1_COLS, # ← 동일 λ„ˆλΉ„
2437
  "gap": ROW_GAP,
2438
  "padding": PAGE_PAD,
2439
  "marginBottom":"22px",
@@ -2457,18 +2459,30 @@ app.layout = html.Div(
2457
  ],
2458
  style={"display":"flex","justifyContent":"flex-end","alignItems":"center","marginBottom":"6px"},
2459
  ),
2460
- dcc.Graph(id="fig-stage-rank", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
 
 
 
 
2461
  ],
2462
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"},
2463
  ),
2464
 
2465
  html.Div(
2466
- dcc.Graph(id="fig-forest", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
 
 
 
 
2467
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"}
2468
  ),
2469
 
2470
  html.Div(
2471
- dcc.Graph(id="fig-bubble", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
 
 
 
 
2472
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"}
2473
  ),
2474
  ],
@@ -2484,8 +2498,8 @@ app.layout = html.Div(
2484
  # μˆ¨κΉ€ κ·Έλž˜ν”„
2485
  html.Div(
2486
  [
2487
- dcc.Graph(id="fig-survival", config=GRAPH_CONFIG),
2488
- dcc.Graph(id="fig-funnel", config=GRAPH_CONFIG),
2489
  ],
2490
  style={"display":"none"},
2491
  ),
@@ -2899,14 +2913,15 @@ def update_all(seg, mod, loy, drag_val, stage_label, tab_right,
2899
  empty, empty, empty, empty, empty, empty, empty, empty
2900
  )
2901
 
2902
- # === [HF ADD] μ„œλ²„ 기동뢀 ===
2903
  if __name__ == "__main__":
2904
- HOST = "0.0.0.0"
2905
- import os
2906
- PORT = int(os.getenv("PORT", "7860"))
2907
- try:
2908
- app # Dash μΈμŠ€ν„΄μŠ€κ°€ 전역에 μžˆμ–΄μ•Ό 함 (예: app = Dash(__name__))
2909
- except NameError as e:
2910
- raise SystemExit("❌ 'app' 객체가 ν•„μš”ν•©λ‹ˆλ‹€. (app = Dash(__name__))") from e
2911
- app.run_server(host=HOST, port=PORT, debug=False)
 
2912
 
 
43
  "showTips": True,
44
  }
45
 
46
+ # ===================== 기본 경둜 =====================
47
+ DEFAULT_PATH = r"/content/drive/MyDrive/baye_dash/bayesian_analysis_total_v1.xlsx"
 
 
 
 
 
 
 
 
48
 
49
  # ===================== 레벨 μƒμˆ˜ =====================
50
  LEVEL_OVERALL="전체"; LEVEL_SEGMENT="μ„Έκ·Έλ¨ΌνŠΈ"; LEVEL_MODEL="λͺ¨λΈ"
 
2300
  return fig
2301
 
2302
  # ───────────────── app.layout ꡐ체 ─────────────────
 
2303
  ROW_GAP = "16px" # μΉ΄λ“œ 사이 간격
2304
  PAGE_PAD = "24px 28px 24px" # ν–‰ μ•ˆμͺ½ νŒ¨λ”©
2305
  CARD_H = "430px" # μΉ΄λ“œ(λ°•μŠ€) 높이
 
2309
  ROW1_COLS = "1fr 1fr 1fr" # 상단 3μΉ΄λ“œ 동일 λ„ˆλΉ„
2310
  ROW2_COLS = "1fr 1fr 1fr" # ν•˜λ‹¨ 3μΉ΄λ“œ 동일 λ„ˆλΉ„
2311
 
 
2312
  app.layout = html.Div(
2313
  [
2314
  dcc.Store(id="store-master"),
 
2397
  html.Div(
2398
  [
2399
  html.Div(
2400
+ dcc.Graph(
2401
+ id="fig-sankey",
2402
+ config=GRAPH_CONFIG | {"responsive": True},
2403
+ style={"height": GRAPH_H, "width": "100%"}
2404
+ ),
2405
+ style={**CARD_STYLE, "height": CARD_H, "overflow": "hidden"} # ← κ³ μ •/클립
2406
  ),
2407
 
2408
  html.Div(
2409
+ dcc.Graph(
2410
+ id="fig-matrix",
2411
+ config=GRAPH_CONFIG | {"responsive": True},
2412
+ style={"height": GRAPH_H, "width": "100%"}
2413
+ ),
2414
+ style={**CARD_STYLE, "height": CARD_H, "overflow": "hidden"}
2415
  ),
2416
 
2417
  html.Div(
 
2424
  ],
2425
  style={"marginBottom":"6px"},
2426
  ),
2427
+ dcc.Graph(
2428
+ id="fig-right",
2429
+ config=GRAPH_CONFIG | {"responsive": True},
2430
+ style={"height": GRAPH_H, "width": "100%"}
2431
+ ),
2432
  ],
2433
+ style={**CARD_STYLE, "height": CARD_H, "overflow": "hidden"},
2434
  ),
2435
  ],
2436
  style={
2437
  "display":"grid",
2438
+ "gridTemplateColumns": ROW1_COLS,
2439
  "gap": ROW_GAP,
2440
  "padding": PAGE_PAD,
2441
  "marginBottom":"22px",
 
2459
  ],
2460
  style={"display":"flex","justifyContent":"flex-end","alignItems":"center","marginBottom":"6px"},
2461
  ),
2462
+ dcc.Graph(
2463
+ id="fig-stage-rank",
2464
+ config=GRAPH_CONFIG | {"responsive": True},
2465
+ style={"height": GRAPH_H, "width": "100%"}
2466
+ ),
2467
  ],
2468
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"},
2469
  ),
2470
 
2471
  html.Div(
2472
+ dcc.Graph(
2473
+ id="fig-forest",
2474
+ config=GRAPH_CONFIG | {"responsive": True},
2475
+ style={"height": GRAPH_H, "width": "100%"}
2476
+ ),
2477
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"}
2478
  ),
2479
 
2480
  html.Div(
2481
+ dcc.Graph(
2482
+ id="fig-bubble",
2483
+ config=GRAPH_CONFIG | {"responsive": True},
2484
+ style={"height": GRAPH_H, "width": "100%"}
2485
+ ),
2486
  style={**CARD_STYLE, "height": CARD_H, "overflow":"hidden"}
2487
  ),
2488
  ],
 
2498
  # μˆ¨κΉ€ κ·Έλž˜ν”„
2499
  html.Div(
2500
  [
2501
+ dcc.Graph(id="fig-survival", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
2502
+ dcc.Graph(id="fig-funnel", config=GRAPH_CONFIG, style={"height": GRAPH_H}),
2503
  ],
2504
  style={"display":"none"},
2505
  ),
 
2913
  empty, empty, empty, empty, empty, empty, empty, empty
2914
  )
2915
 
2916
+ # ===================== μ‹€ν–‰ =====================
2917
  if __name__ == "__main__":
2918
+ base_port = int(os.getenv("PORT", "8059"))
2919
+ for i in range(5):
2920
+ try:
2921
+ app.run_server(host="0.0.0.0", port=base_port + i, debug=False, use_reloader=False)
2922
+ break
2923
+ except (OSError, SystemExit) as e:
2924
+ if "Address already in use" in str(e) or getattr(e, "code", None) == 1:
2925
+ continue
2926
+ raise
2927