Spaces:
Sleeping
Sleeping
Sync from GitHub via hub-sync
Browse files- filter_engine.py +9 -5
filter_engine.py
CHANGED
|
@@ -134,8 +134,10 @@ def _(EXAMPLE_DATASETS, mo):
|
|
| 134 |
options=["Load example", "Upload your own"],
|
| 135 |
value="Load example",
|
| 136 |
)
|
|
|
|
| 137 |
example_picker = mo.ui.dropdown(
|
| 138 |
-
options=
|
|
|
|
| 139 |
label="Example dataset",
|
| 140 |
)
|
| 141 |
sample_file = mo.ui.file(kind="area", filetypes=[".csv"])
|
|
@@ -241,11 +243,12 @@ def _(df_selected, initial_date_column, initial_yaml, mo):
|
|
| 241 |
|
| 242 |
|
| 243 |
@app.cell
|
| 244 |
-
def _(df_selected, load_profile, mo, yaml, yaml_editor):
|
| 245 |
-
|
|
|
|
| 246 |
|
| 247 |
try:
|
| 248 |
-
_parsed = yaml.safe_load(
|
| 249 |
except yaml.YAMLError as _e:
|
| 250 |
mo.stop(True, mo.callout(mo.md(f"**Invalid YAML:** {_e}"), kind="danger"))
|
| 251 |
|
|
@@ -309,7 +312,8 @@ def _(mo):
|
|
| 309 |
|
| 310 |
|
| 311 |
@app.cell
|
| 312 |
-
def _(df_selected):
|
|
|
|
| 313 |
df_selected.sample(10)
|
| 314 |
return
|
| 315 |
|
|
|
|
| 134 |
options=["Load example", "Upload your own"],
|
| 135 |
value="Load example",
|
| 136 |
)
|
| 137 |
+
_datasets = list(EXAMPLE_DATASETS.keys())
|
| 138 |
example_picker = mo.ui.dropdown(
|
| 139 |
+
options=_datasets,
|
| 140 |
+
value=_datasets[0] if _datasets else None,
|
| 141 |
label="Example dataset",
|
| 142 |
)
|
| 143 |
sample_file = mo.ui.file(kind="area", filetypes=[".csv"])
|
|
|
|
| 243 |
|
| 244 |
|
| 245 |
@app.cell
|
| 246 |
+
def _(df_selected, initial_yaml, load_profile, mo, yaml, yaml_editor):
|
| 247 |
+
_yaml_to_use = yaml_editor.value if yaml_editor.value is not None else initial_yaml
|
| 248 |
+
mo.stop(_yaml_to_use is None)
|
| 249 |
|
| 250 |
try:
|
| 251 |
+
_parsed = yaml.safe_load(_yaml_to_use)
|
| 252 |
except yaml.YAMLError as _e:
|
| 253 |
mo.stop(True, mo.callout(mo.md(f"**Invalid YAML:** {_e}"), kind="danger"))
|
| 254 |
|
|
|
|
| 312 |
|
| 313 |
|
| 314 |
@app.cell
|
| 315 |
+
def _(df_selected, mo):
|
| 316 |
+
mo.stop(df_selected is None)
|
| 317 |
df_selected.sample(10)
|
| 318 |
return
|
| 319 |
|