RathodHarish commited on
Commit
110e018
·
verified ·
1 Parent(s): 4f94010

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -5,7 +5,6 @@ import logging
5
  import plotly.express as px
6
  from sklearn.ensemble import IsolationForest # For anomaly detection
7
  from transformers import pipeline
8
- import dask.dataframe as dd # For handling large datasets
9
 
10
  # Configure logging for debugging
11
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -167,11 +166,10 @@ def process_logs(file_obj, progress=gr.Progress()):
167
  logging.error("Unsupported file format")
168
  return "Unsupported file format. Please upload a CSV file.", None, None, None, None, None
169
 
170
- # Use Dask for large CSV files to read in chunks
171
  progress(0.05, "Loading CSV file...")
172
  try:
173
- ddf = dd.from_pandas(pd.read_csv(file_name), npartitions=4) # Split into 4 partitions
174
- df = ddf.compute() # Convert back to pandas after processing
175
  logging.info(f"File loaded successfully with {len(df)} rows")
176
  except Exception as e:
177
  logging.error(f"Failed to load CSV: {str(e)}")
@@ -217,7 +215,7 @@ def process_logs(file_obj, progress=gr.Progress()):
217
  # Step 5: AMC Reminders
218
  amc_reminders = f"**Step 4: AMC Reminders**\n{check_amc_reminders(df, datetime.now(), progress)}\n---\n"
219
 
220
- # Stepabba 6: Dashboard Insights
221
  insights = f"**Step 5: Dashboard Insights (AI)**\n{generate_dashboard_insights(df, progress)}\n---\n"
222
 
223
  progress(1.0, "Processing complete!")
@@ -226,7 +224,7 @@ def process_logs(file_obj, progress=gr.Progress()):
226
  logging.error(f"Failed to process file: {str(e)}")
227
  return f"Failed to process file: {str(e)}", None, None, None, None, None
228
 
229
- # Gr{dimadio Interface with Step-by-Step Layout
230
  try:
231
  logging.info("Initializing Gradio Blocks interface...")
232
  with gr.Blocks(css="""
 
5
  import plotly.express as px
6
  from sklearn.ensemble import IsolationForest # For anomaly detection
7
  from transformers import pipeline
 
8
 
9
  # Configure logging for debugging
10
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
166
  logging.error("Unsupported file format")
167
  return "Unsupported file format. Please upload a CSV file.", None, None, None, None, None
168
 
169
+ # Use pandas to load CSV (removed dask dependency)
170
  progress(0.05, "Loading CSV file...")
171
  try:
172
+ df = pd.read_csv(file_name)
 
173
  logging.info(f"File loaded successfully with {len(df)} rows")
174
  except Exception as e:
175
  logging.error(f"Failed to load CSV: {str(e)}")
 
215
  # Step 5: AMC Reminders
216
  amc_reminders = f"**Step 4: AMC Reminders**\n{check_amc_reminders(df, datetime.now(), progress)}\n---\n"
217
 
218
+ # Step 6: Dashboard Insights
219
  insights = f"**Step 5: Dashboard Insights (AI)**\n{generate_dashboard_insights(df, progress)}\n---\n"
220
 
221
  progress(1.0, "Processing complete!")
 
224
  logging.error(f"Failed to process file: {str(e)}")
225
  return f"Failed to process file: {str(e)}", None, None, None, None, None
226
 
227
+ # Gradio Interface with Step-by-Step Layout
228
  try:
229
  logging.info("Initializing Gradio Blocks interface...")
230
  with gr.Blocks(css="""