Corin1998 commited on
Commit
c3fe8e0
·
verified ·
1 Parent(s): 762a2c6

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +12 -5
ui.py CHANGED
@@ -1,17 +1,24 @@
 
 
 
1
  import os
2
  os.environ.setdefault("APP_DATA_DIR", "/data/app_data" if os.access("/data", os.W_OK) else "/tmp/app_data")
3
  os.environ.setdefault("MPLCONFIGDIR", os.path.join(os.environ["APP_DATA_DIR"], "mplconfig"))
4
  os.makedirs(os.environ["MPLCONFIGDIR"], exist_ok=True)
 
5
 
6
- from __future__ import annotations
7
- import os, json, uuid
8
  from datetime import datetime
9
- from typing import List, Dict, Any
10
 
11
  import gradio as gr
12
  import pandas as pd
13
 
14
- from app.storage import init_db, insert_variant, upsert_campaign, get_variant, get_metrics, get_campaign_value_per_conversion, log_event
 
 
 
15
  from app.bandit import ThompsonBandit
16
  from app.forecast import SeasonalityModel
17
  from app.compliance import rule_based_check, llm_check_and_fix
@@ -170,7 +177,7 @@ with gr.Blocks(title="AdCopy MAB Optimizer", fill_height=True) as demo:
170
  # AdCopy MAB Optimizer(HF UI)
171
  **広告コピー自動生成 → Thompson Sampling(CTR×CVR) → レポート** を、Hugging Face Spaces 上で完結。
172
  - LLM: OpenAI (`OPENAI_API_KEY` を Space Secrets に設定)
173
- - DB: SQLite(`data/data.db`)
174
  - 季節性: Prophet/NeuralProphet(なければ簡易ヒューリスティック)
175
  """)
176
 
 
1
+ from __future__ import annotations
2
+
3
+ # === Writable config dirs (must come right after future import) ===
4
  import os
5
  os.environ.setdefault("APP_DATA_DIR", "/data/app_data" if os.access("/data", os.W_OK) else "/tmp/app_data")
6
  os.environ.setdefault("MPLCONFIGDIR", os.path.join(os.environ["APP_DATA_DIR"], "mplconfig"))
7
  os.makedirs(os.environ["MPLCONFIGDIR"], exist_ok=True)
8
+ # =================================================================
9
 
10
+ import json
11
+ import uuid
12
  from datetime import datetime
13
+ from typing import Dict
14
 
15
  import gradio as gr
16
  import pandas as pd
17
 
18
+ from app.storage import (
19
+ init_db, insert_variant, upsert_campaign, get_variant, get_metrics,
20
+ get_campaign_value_per_conversion, log_event
21
+ )
22
  from app.bandit import ThompsonBandit
23
  from app.forecast import SeasonalityModel
24
  from app.compliance import rule_based_check, llm_check_and_fix
 
177
  # AdCopy MAB Optimizer(HF UI)
178
  **広告コピー自動生成 → Thompson Sampling(CTR×CVR) → レポート** を、Hugging Face Spaces 上で完結。
179
  - LLM: OpenAI (`OPENAI_API_KEY` を Space Secrets に設定)
180
+ - DB: SQLite(`/data/app_data/data.db` など、書き込み可能ディレクトリ)
181
  - 季節性: Prophet/NeuralProphet(なければ簡易ヒューリスティック)
182
  """)
183