RathodHarish commited on
Commit
41f1d58
·
verified ·
1 Parent(s): 95fa040

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -20,8 +20,8 @@ def upload_csv(file):
20
  if df.empty:
21
  return ["All"], ["All"], ["All"], "The uploaded CSV file is empty.", "All", "All", "All"
22
 
23
- # Define required columns
24
- required_columns = {'DeviceID', 'Lab', 'Type', 'Timestamp', 'Status', 'UsageCount', 'Health'}
25
  if not required_columns.issubset(df.columns):
26
  missing_cols = required_columns - set(df.columns)
27
  return ["All"], ["All"], ["All"], f"CSV is missing required columns: {', '.join(missing_cols)}", "All", "All", "All"
@@ -62,8 +62,8 @@ def filter_and_visualize(selected_lab, selected_type, selected_date_range):
62
  if filtered_df.empty:
63
  return None, None, None, None, "No data matches the selected filters."
64
 
65
- # Device Cards (as a table)
66
- device_cards = filtered_df[['DeviceID', 'Lab', 'Type', 'Health', 'UsageCount', 'Timestamp']].sort_values(by='Timestamp', ascending=False)
67
 
68
  # Daily Log Trends (Line Chart)
69
  daily_logs = filtered_df.groupby(filtered_df['Timestamp'].dt.date).size()
@@ -128,9 +128,9 @@ def download_pdf(selected_lab, selected_type, selected_date_range):
128
  pdf.cell(200, 10, txt="LabOps Dashboard Report", ln=True, align='C')
129
  pdf.ln(10)
130
 
131
- # Add filtered data
132
  for index, row in filtered_df.iterrows():
133
- line = f"{row['Timestamp']} | {row['DeviceID']} | {row['Lab']} | {row['Type']} | {row['Status']} | {row['UsageCount']} | {row['Health']}"
134
  pdf.multi_cell(0, 10, txt=line)
135
 
136
  output = io.BytesIO()
@@ -151,7 +151,7 @@ with gr.Blocks() as demo:
151
  date_dropdown = gr.Dropdown(label="Filter by Date Range", choices=["All"], value="All")
152
 
153
  with gr.Row():
154
- device_table = gr.DataFrame(label="Device Cards (Health, Usage, Last Log)")
155
  plot_daily = gr.Image(label="Daily Log Trends")
156
  plot_uptime = gr.Image(label="Weekly Uptime %")
157
 
 
20
  if df.empty:
21
  return ["All"], ["All"], ["All"], "The uploaded CSV file is empty.", "All", "All", "All"
22
 
23
+ # Define required columns (removed 'Health')
24
+ required_columns = {'DeviceID', 'Lab', 'Type', 'Timestamp', 'Status', 'UsageCount'}
25
  if not required_columns.issubset(df.columns):
26
  missing_cols = required_columns - set(df.columns)
27
  return ["All"], ["All"], ["All"], f"CSV is missing required columns: {', '.join(missing_cols)}", "All", "All", "All"
 
62
  if filtered_df.empty:
63
  return None, None, None, None, "No data matches the selected filters."
64
 
65
+ # Device Cards (as a table, removed 'Health')
66
+ device_cards = filtered_df[['DeviceID', 'Lab', 'Type', 'UsageCount', 'Timestamp']].sort_values(by='Timestamp', ascending=False)
67
 
68
  # Daily Log Trends (Line Chart)
69
  daily_logs = filtered_df.groupby(filtered_df['Timestamp'].dt.date).size()
 
128
  pdf.cell(200, 10, txt="LabOps Dashboard Report", ln=True, align='C')
129
  pdf.ln(10)
130
 
131
+ # Add filtered data (removed 'Health')
132
  for index, row in filtered_df.iterrows():
133
+ line = f"{row['Timestamp']} | {row['DeviceID']} | {row['Lab']} | {row['Type']} | {row['Status']} | {row['UsageCount']}"
134
  pdf.multi_cell(0, 10, txt=line)
135
 
136
  output = io.BytesIO()
 
151
  date_dropdown = gr.Dropdown(label="Filter by Date Range", choices=["All"], value="All")
152
 
153
  with gr.Row():
154
+ device_table = gr.DataFrame(label="Device Cards (Usage, Last Log)")
155
  plot_daily = gr.Image(label="Daily Log Trends")
156
  plot_uptime = gr.Image(label="Weekly Uptime %")
157