Spaces:
Sleeping
Sleeping
Commit
·
5c5efaf
1
Parent(s):
19997c8
More warnings before running
Browse files
app.py
CHANGED
|
@@ -20,6 +20,7 @@ def greet(
|
|
| 20 |
niterations: int,
|
| 21 |
binary_operators: list,
|
| 22 |
unary_operators: list,
|
|
|
|
| 23 |
):
|
| 24 |
if col_to_fit == "":
|
| 25 |
return (
|
|
@@ -36,6 +37,31 @@ def greet(
|
|
| 36 |
empty_df,
|
| 37 |
"Please upload a CSV file!",
|
| 38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
binary_operators = str(binary_operators).replace("'", '"')
|
| 41 |
unary_operators = str(unary_operators).replace("'", '"')
|
|
@@ -75,6 +101,10 @@ def main():
|
|
| 75 |
label="Unary Operators",
|
| 76 |
default=[],
|
| 77 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
],
|
| 79 |
outputs=[
|
| 80 |
"dataframe",
|
|
|
|
| 20 |
niterations: int,
|
| 21 |
binary_operators: list,
|
| 22 |
unary_operators: list,
|
| 23 |
+
force_run: bool,
|
| 24 |
):
|
| 25 |
if col_to_fit == "":
|
| 26 |
return (
|
|
|
|
| 37 |
empty_df,
|
| 38 |
"Please upload a CSV file!",
|
| 39 |
)
|
| 40 |
+
# Look at some statistics of the file:
|
| 41 |
+
df = pd.read_csv(file_obj.name)
|
| 42 |
+
if len(df) == 0:
|
| 43 |
+
return (
|
| 44 |
+
empty_df,
|
| 45 |
+
"The file is empty!",
|
| 46 |
+
)
|
| 47 |
+
if len(df.columns) == 1:
|
| 48 |
+
return (
|
| 49 |
+
empty_df,
|
| 50 |
+
"The file has only one column!",
|
| 51 |
+
)
|
| 52 |
+
if col_to_fit not in df.columns:
|
| 53 |
+
return (
|
| 54 |
+
empty_df,
|
| 55 |
+
"The column to predict is not in the file!",
|
| 56 |
+
)
|
| 57 |
+
if len(df) > 1000 and not force_run:
|
| 58 |
+
return (
|
| 59 |
+
empty_df,
|
| 60 |
+
"You have uploaded a file with more than 2000 rows. "
|
| 61 |
+
"This will take very long to run. "
|
| 62 |
+
"Please upload a subsample of the data, "
|
| 63 |
+
"or check the box 'Ignore Warnings'."
|
| 64 |
+
)
|
| 65 |
|
| 66 |
binary_operators = str(binary_operators).replace("'", '"')
|
| 67 |
unary_operators = str(unary_operators).replace("'", '"')
|
|
|
|
| 101 |
label="Unary Operators",
|
| 102 |
default=[],
|
| 103 |
),
|
| 104 |
+
gr.inputs.Checkbox(
|
| 105 |
+
default=False,
|
| 106 |
+
label="Ignore Warnings",
|
| 107 |
+
)
|
| 108 |
],
|
| 109 |
outputs=[
|
| 110 |
"dataframe",
|