Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -134,11 +134,12 @@ def show_violin_plot(df):
|
|
| 134 |
|
| 135 |
def generate_streamlit_app_code(app_title, app_subtitle, side_panel_title, analysis_tasks, requirements):
|
| 136 |
# Generate Python code for the Streamlit app
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
code = f"""
|
| 141 |
-
import streamlit as st
|
| 142 |
import pandas as pd
|
| 143 |
import seaborn as sns
|
| 144 |
import plotly.express as px
|
|
@@ -159,9 +160,10 @@ def main():
|
|
| 159 |
|
| 160 |
df = load_data(uploaded_file)
|
| 161 |
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
|
|
|
| 165 |
|
| 166 |
if __name__ == "__main__":
|
| 167 |
main()
|
|
|
|
| 134 |
|
| 135 |
def generate_streamlit_app_code(app_title, app_subtitle, side_panel_title, analysis_tasks, requirements):
|
| 136 |
# Generate Python code for the Streamlit app
|
| 137 |
+
# Here we make sure the analysis functions are correctly indented at the same level as the main function
|
| 138 |
+
analysis_functions_code = "\n ".join([PREDEFINED_ANALYSIS[task]['Code'].replace("\n", "\n ") for task in analysis_tasks])
|
| 139 |
+
# Here we ensure that calls to analysis functions are correctly indented within the main function
|
| 140 |
+
analysis_tasks_code = "\n ".join([f" {PREDEFINED_ANALYSIS[task]['Function']}(df)" for task in analysis_tasks])
|
| 141 |
|
| 142 |
+
code = f"""import streamlit as st
|
|
|
|
| 143 |
import pandas as pd
|
| 144 |
import seaborn as sns
|
| 145 |
import plotly.express as px
|
|
|
|
| 160 |
|
| 161 |
df = load_data(uploaded_file)
|
| 162 |
|
| 163 |
+
{analysis_functions_code}
|
| 164 |
|
| 165 |
+
# Analysis task calls
|
| 166 |
+
{analysis_tasks_code}
|
| 167 |
|
| 168 |
if __name__ == "__main__":
|
| 169 |
main()
|