Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import shutil
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
def run_e2e_pipeline(input_file):
|
| 7 |
+
# Save uploaded file to the expected input location
|
| 8 |
+
input_path = "CONFIG/CONFIG/data/sample_data.csv"
|
| 9 |
+
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
| 10 |
+
shutil.copy(input_file.name, input_path)
|
| 11 |
+
|
| 12 |
+
# Run the E2E PowerShell pipeline
|
| 13 |
+
result = subprocess.run(
|
| 14 |
+
["powershell", "-ExecutionPolicy", "Bypass", "-File", "runbook/runbook/pipeline/14_run_full_pipeline.ps1"],
|
| 15 |
+
capture_output=True, text=True
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Collect output files
|
| 19 |
+
outputs = [
|
| 20 |
+
"outputs/outputs/converted_phase1.csv",
|
| 21 |
+
"Validation/Validation/Reports/PHASE1_VALIDATION_REPORT.json",
|
| 22 |
+
"Validation/Validation/Reports/PHASE1_SIGNALS_REPORT.json"
|
| 23 |
+
]
|
| 24 |
+
downloadable = [f for f in outputs if os.path.exists(f)]
|
| 25 |
+
|
| 26 |
+
return result.stdout, downloadable
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
with gr.Blocks(css="""
|
| 31 |
+
body {
|
| 32 |
+
background: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=1500&q=80') no-repeat center center fixed !important;
|
| 33 |
+
background-size: cover !important;
|
| 34 |
+
}
|
| 35 |
+
#header {
|
| 36 |
+
background: rgba(255,255,255,0.92);
|
| 37 |
+
border-radius: 24px;
|
| 38 |
+
margin-bottom: 24px;
|
| 39 |
+
box-shadow: 0 8px 32px #0002;
|
| 40 |
+
border: 2px solid #43c6ac;
|
| 41 |
+
}
|
| 42 |
+
.gr-button {
|
| 43 |
+
font-size: 1.3em;
|
| 44 |
+
background: linear-gradient(90deg, #43c6ac 0%, #191654 100%);
|
| 45 |
+
color: #fff;
|
| 46 |
+
border-radius: 12px;
|
| 47 |
+
border: 2px solid #191654;
|
| 48 |
+
box-shadow: 0 2px 8px #0002;
|
| 49 |
+
}
|
| 50 |
+
.gr-button:hover {
|
| 51 |
+
background: linear-gradient(90deg, #191654 0%, #43c6ac 100%);
|
| 52 |
+
color: #fff;
|
| 53 |
+
}
|
| 54 |
+
.gr-box {
|
| 55 |
+
background: #fffbe7cc;
|
| 56 |
+
border-radius: 16px;
|
| 57 |
+
border: 1.5px solid #43c6ac;
|
| 58 |
+
box-shadow: 0 2px 8px #0001;
|
| 59 |
+
}
|
| 60 |
+
#footer {
|
| 61 |
+
text-align:center;
|
| 62 |
+
margin-top:32px;
|
| 63 |
+
color:#fff;
|
| 64 |
+
font-size:1.1em;
|
| 65 |
+
text-shadow: 0 2px 8px #0008;
|
| 66 |
+
}
|
| 67 |
+
""") as demo:
|
| 68 |
+
gr.Markdown("""
|
| 69 |
+
<div id='header' style='text-align:center; padding: 8px 0 8px 0;'>
|
| 70 |
+
<h1 style='font-size:2.7em; margin-bottom:0.2em; letter-spacing:2px;'>
|
| 71 |
+
<span style='font-size:1.2em;'>π</span> <span style='color:#191654;'>Phase1 <span style='color:#43c6ac;'>E2E Pipeline</span> UI</span> <span style='font-size:1.2em;'>π€</span>
|
| 72 |
+
</h1>
|
| 73 |
+
<img src='https://img.icons8.com/color/192/000000/artificial-intelligence.png' alt='AI Icon' style='margin-bottom:10px; border-radius:50%; box-shadow:0 2px 16px #43c6ac;'>
|
| 74 |
+
<!-- Icons removed for cleaner look -->
|
| 75 |
+
<p style='font-size:1.25em; color:#191654; margin-top:18px;'>
|
| 76 |
+
Upload your <b>input CSV</b>, run the full pipeline, and download the outputs.<br>
|
| 77 |
+
<span style='color:#43c6ac;'>Enjoy a seamless local AI experience! π</span>
|
| 78 |
+
</p>
|
| 79 |
+
</div>
|
| 80 |
+
""")
|
| 81 |
+
gr.Markdown("""
|
| 82 |
+
<div style='font-size:1.15em; background:linear-gradient(90deg,#f8ffae,#43c6ac33); border-radius:16px; padding:16px; margin-bottom:16px; box-shadow:0 2px 8px #43c6ac22;'>
|
| 83 |
+
<ul style='list-style:none; padding-left:0;'>
|
| 84 |
+
<li>π <b style='color:#43c6ac;'>Upload</b> your <code>sample_data.csv</code> <img src='https://img.icons8.com/fluency/32/upload.png' style='vertical-align:middle; margin-left:4px;'></li>
|
| 85 |
+
<li>β‘ <b style='color:#43c6ac;'>Run</b> the pipeline <img src='https://img.icons8.com/fluency/32/play.png' style='vertical-align:middle; margin-left:4px;'></li>
|
| 86 |
+
<li>π₯ <b style='color:#43c6ac;'>Download</b> your results <img src='https://img.icons8.com/fluency/32/download.png' style='vertical-align:middle; margin-left:4px;'></li>
|
| 87 |
+
</ul>
|
| 88 |
+
</div>
|
| 89 |
+
""")
|
| 90 |
+
|
| 91 |
+
file_input = gr.File(label="π Upload sample_data.csv")
|
| 92 |
+
output_console = gr.Textbox(label="π Pipeline Output", lines=10)
|
| 93 |
+
output_files = gr.Files(label="π₯ Generated Output Files")
|
| 94 |
+
btn = gr.Button("π¦ Run E2E Pipeline")
|
| 95 |
+
btn.click(run_e2e_pipeline, file_input, [output_console, output_files])
|
| 96 |
+
|
| 97 |
+
gr.Markdown("""
|
| 98 |
+
<div id='footer'>
|
| 99 |
+
<span style='font-size:1.2em;'>β¨</span> <b>Phase1 Local AI Solution</b> — <span style='color:#43c6ac;'>Built with Gradio</span> <span style='font-size:1.2em;'>π€©</span>
|
| 100 |
+
</div>
|
| 101 |
+
""")
|
| 102 |
+
|
| 103 |
+
if __name__ == "__main__":
|
| 104 |
+
demo.launch(server_name="127.0.0.1", server_port=7860, ssr_mode=False)
|