Spaces:
Runtime error
Runtime error
| # app.py (Gradio-based Hugging Face Space Template) | |
| import gradio as gr | |
| import pandas as pd | |
| import plotly.express as px | |
| from utils.model import predict_timeline | |
| from utils.salesforce import fetch_project_data | |
| from utils.export import export_summary_pdf | |
| def process_file(file): | |
| df = pd.read_excel(file.name if hasattr(file, 'name') else file) | |
| gantt_data, delay_risks, summary = predict_timeline(df) | |
| gantt_fig = px.timeline(gantt_data, x_start="Start", x_end="Finish", y="Task", color="Risk") | |
| gantt_fig.update_yaxes(autorange="reversed") | |
| return df, gantt_fig, delay_risks, summary | |
| def generate_pdf(summary): | |
| return export_summary_pdf(summary) | |
| with gr.Blocks() as app: | |
| gr.Markdown("## Infrastructure Project Planner") | |
| with gr.Row(): | |
| file_input = gr.File(label="Upload BOQ / Scope (Excel)", type="file") | |
| fetch_button = gr.Button("Fetch from Salesforce") | |
| with gr.Row(): | |
| preview = gr.Dataframe(label="BOQ Preview") | |
| gantt_plot = gr.Plot(label="Project Gantt Chart") | |
| risk_display = gr.HighlightedText(label="Delay Risk Analysis") | |
| summary_output = gr.Textbox(label="Project Summary", lines=5) | |
| pdf_button = gr.Button("Export PDF") | |
| pdf_output = gr.File(label="Download Project Kickoff Summary") | |
| file_input.change(process_file, inputs=file_input, outputs=[preview, gantt_plot, risk_display, summary_output]) | |
| fetch_button.click(fetch_project_data, outputs=file_input) | |
| pdf_button.click(generate_pdf, inputs=summary_output, outputs=pdf_output) | |
| app.launch() |