harikrishnad1997 commited on
Commit
9c3faa5
1 Parent(s): 71fc0ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -30,7 +30,7 @@ def plot_scatter(file_contents, x_axis, y_axis):
30
  plt.ylabel(y_axis)
31
  return plt
32
 
33
- def layout_fn(inputs, outputs):
34
  # Get the data from uploaded file
35
  data = pd.read_csv(StringIO(inputs.file))
36
 
@@ -75,20 +75,17 @@ interface = gr.Interface(
75
  description="Upload a CSV file, select columns for histogram and scatter plots.",
76
  )
77
 
78
- # Set dropdown options dynamically based on uploaded data
79
- interface.component_args["text"] = {"choices": None}
80
- interface.component_args["text_1"] = {"choices": None}
81
- interface.component_args["text_2"] = {"choices": None}
82
 
83
-
84
- @interface.update(enabled=False)
85
- def update_choices(file):
86
- if file:
87
- data = pd.read_csv(StringIO(file.getvalue()))
88
  choices = list(data.columns)
89
- interface.component_args["text"] = {"choices": choices}
90
- interface.component_args["text_1"] = {"choices": choices}
91
- interface.component_args["text_2"] = {"choices": choices}
 
 
92
 
93
 
94
  interface.launch(share=True)
 
30
  plt.ylabel(y_axis)
31
  return plt
32
 
33
+ def layout_fn(inputs):
34
  # Get the data from uploaded file
35
  data = pd.read_csv(StringIO(inputs.file))
36
 
 
75
  description="Upload a CSV file, select columns for histogram and scatter plots.",
76
  )
77
 
 
 
 
 
78
 
79
+ @interface.update # Use update method instead of component_args
80
+ def update_choices(inputs):
81
+ if inputs.file:
82
+ data = pd.read_csv(StringIO(inputs.file.getvalue()))
 
83
  choices = list(data.columns)
84
+ interface.update( # Update interface options using update
85
+ text=gr.components.Dropdown(choices=choices),
86
+ text_1=gr.components.Dropdown(choices=choices),
87
+ text_2=gr.components.Dropdown(choices=choices),
88
+ )
89
 
90
 
91
  interface.launch(share=True)