Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,9 +26,8 @@ import threading
|
|
| 26 |
|
| 27 |
storage.init_db()
|
| 28 |
|
| 29 |
-
# ---
|
| 30 |
def start_cache_build():
|
| 31 |
-
"""Starts the 45-minute scan in the background so the UI doesn't crash."""
|
| 32 |
try:
|
| 33 |
import historic_llm_backtest
|
| 34 |
import importlib
|
|
@@ -47,14 +46,14 @@ def start_cache_build():
|
|
| 47 |
return f"❌ Error starting scan: {str(e)}"
|
| 48 |
|
| 49 |
def check_and_download_cache():
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
return None, "❌ Not ready yet. Check your terminal logs to see if it's still scanning."
|
| 54 |
|
| 55 |
# --- SIMULATION FUNCTIONS ---
|
| 56 |
def trigger_chunked():
|
| 57 |
-
"""Triggers the 16-year chunked LLM backtest in the background."""
|
| 58 |
try:
|
| 59 |
import historic_llm_backtest
|
| 60 |
import importlib
|
|
@@ -85,7 +84,6 @@ with gr.Blocks(title="Kairo 14.1: Renaissance Engine", theme=gr.themes.Soft(), c
|
|
| 85 |
gr.Markdown("# 🦅 Kairo 14.1: The Alpha Engine (AI Macro Edition)")
|
| 86 |
gr.Markdown("Zero-Leverage | Walk-Forward Market Evolution | 16-Year LLM Context Analysis")
|
| 87 |
|
| 88 |
-
# --- NEW CACHE TOOLKIT ---
|
| 89 |
with gr.Accordion("🛠️ Data Tools: Permanent Cache Builder", open=True):
|
| 90 |
gr.Markdown("**Step 1:** Build the cache (takes ~45 mins). **Step 2:** Download it. **Step 3:** Upload it to your Hugging Face Space 'Files' tab permanently.")
|
| 91 |
with gr.Row():
|
|
@@ -104,7 +102,6 @@ with gr.Blocks(title="Kairo 14.1: Renaissance Engine", theme=gr.themes.Soft(), c
|
|
| 104 |
|
| 105 |
live_table_html = gr.HTML(label="Real-Time Picks")
|
| 106 |
|
| 107 |
-
# Event Handlers
|
| 108 |
build_cache_btn.click(start_cache_build, outputs=[sim_status])
|
| 109 |
download_cache_btn.click(check_and_download_cache, outputs=[cache_file, sim_status])
|
| 110 |
|
|
@@ -113,7 +110,6 @@ with gr.Blocks(title="Kairo 14.1: Renaissance Engine", theme=gr.themes.Soft(), c
|
|
| 113 |
reset.click(worker.reset_worker, outputs=sim_status)
|
| 114 |
sim_btn.click(trigger_chunked, outputs=[sim_status])
|
| 115 |
|
| 116 |
-
# Live Timer
|
| 117 |
demo.load(update_ui, outputs=live_table_html)
|
| 118 |
gr.Timer(5).tick(update_ui, outputs=live_table_html)
|
| 119 |
|
|
|
|
| 26 |
|
| 27 |
storage.init_db()
|
| 28 |
|
| 29 |
+
# --- CACHE MANAGEMENT FUNCTIONS ---
|
| 30 |
def start_cache_build():
|
|
|
|
| 31 |
try:
|
| 32 |
import historic_llm_backtest
|
| 33 |
import importlib
|
|
|
|
| 46 |
return f"❌ Error starting scan: {str(e)}"
|
| 47 |
|
| 48 |
def check_and_download_cache():
|
| 49 |
+
import os
|
| 50 |
+
file_path = os.path.abspath("fundamental_cache.json")
|
| 51 |
+
if os.path.exists(file_path):
|
| 52 |
+
return file_path, "✅ Cache Ready! Click the download icon in the file box above."
|
| 53 |
return None, "❌ Not ready yet. Check your terminal logs to see if it's still scanning."
|
| 54 |
|
| 55 |
# --- SIMULATION FUNCTIONS ---
|
| 56 |
def trigger_chunked():
|
|
|
|
| 57 |
try:
|
| 58 |
import historic_llm_backtest
|
| 59 |
import importlib
|
|
|
|
| 84 |
gr.Markdown("# 🦅 Kairo 14.1: The Alpha Engine (AI Macro Edition)")
|
| 85 |
gr.Markdown("Zero-Leverage | Walk-Forward Market Evolution | 16-Year LLM Context Analysis")
|
| 86 |
|
|
|
|
| 87 |
with gr.Accordion("🛠️ Data Tools: Permanent Cache Builder", open=True):
|
| 88 |
gr.Markdown("**Step 1:** Build the cache (takes ~45 mins). **Step 2:** Download it. **Step 3:** Upload it to your Hugging Face Space 'Files' tab permanently.")
|
| 89 |
with gr.Row():
|
|
|
|
| 102 |
|
| 103 |
live_table_html = gr.HTML(label="Real-Time Picks")
|
| 104 |
|
|
|
|
| 105 |
build_cache_btn.click(start_cache_build, outputs=[sim_status])
|
| 106 |
download_cache_btn.click(check_and_download_cache, outputs=[cache_file, sim_status])
|
| 107 |
|
|
|
|
| 110 |
reset.click(worker.reset_worker, outputs=sim_status)
|
| 111 |
sim_btn.click(trigger_chunked, outputs=[sim_status])
|
| 112 |
|
|
|
|
| 113 |
demo.load(update_ui, outputs=live_table_html)
|
| 114 |
gr.Timer(5).tick(update_ui, outputs=live_table_html)
|
| 115 |
|