Sivainti commited on
Commit
4341293
·
verified ·
1 Parent(s): 8550f96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py (Gradio-based Hugging Face Space Template)
2
+
3
+ import gradio as gr
4
+ import pandas as pd
5
+ import plotly.express as px
6
+ from utils.model import predict_timeline
7
+ from utils.salesforce import fetch_project_data
8
+ from utils.export import export_summary_pdf
9
+
10
+
11
+ def process_file(file):
12
+ df = pd.read_excel(file.name if hasattr(file, 'name') else file)
13
+ gantt_data, delay_risks, summary = predict_timeline(df)
14
+
15
+ gantt_fig = px.timeline(gantt_data, x_start="Start", x_end="Finish", y="Task", color="Risk")
16
+ gantt_fig.update_yaxes(autorange="reversed")
17
+
18
+ return df, gantt_fig, delay_risks, summary
19
+
20
+ def generate_pdf(summary):
21
+ return export_summary_pdf(summary)
22
+
23
+ with gr.Blocks() as app:
24
+ gr.Markdown("## Infrastructure Project Planner")
25
+
26
+ with gr.Row():
27
+ file_input = gr.File(label="Upload BOQ / Scope (Excel)", type="file")
28
+ fetch_button = gr.Button("Fetch from Salesforce")
29
+
30
+ with gr.Row():
31
+ preview = gr.Dataframe(label="BOQ Preview")
32
+
33
+ gantt_plot = gr.Plot(label="Project Gantt Chart")
34
+ risk_display = gr.HighlightedText(label="Delay Risk Analysis")
35
+ summary_output = gr.Textbox(label="Project Summary", lines=5)
36
+
37
+ pdf_button = gr.Button("Export PDF")
38
+ pdf_output = gr.File(label="Download Project Kickoff Summary")
39
+
40
+ file_input.change(process_file, inputs=file_input, outputs=[preview, gantt_plot, risk_display, summary_output])
41
+ fetch_button.click(fetch_project_data, outputs=file_input)
42
+ pdf_button.click(generate_pdf, inputs=summary_output, outputs=pdf_output)
43
+
44
+ app.launch()