Skip to content

Commit bcd85a2

Browse files
committed
mldbexport
1 parent 581e74d commit bcd85a2

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

scripts/ml_db_export.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,43 @@ def _():
1717

1818
@app.cell(hide_code=True)
1919
def _(mo, os):
20+
participants_file = mo.ui.file()
21+
data_file = mo.ui.file()
22+
run_button = mo.ui.run_button()
2023
output_dir = mo.ui.text()
24+
filter_to_applet_name = mo.ui.text()
2125
mo.vstack(
2226
[
23-
mo.md("## Output dir"),
24-
mo.md(f"* Current dir: {os.getcwd()}"),
25-
output_dir,
27+
mo.hstack(
28+
[mo.md("### Upload participants file"), participants_file],
29+
justify="start",
30+
),
31+
mo.hstack([mo.md("### Upload data file"), data_file], justify="start"),
32+
mo.hstack(
33+
[
34+
mo.md("### Output dir"),
35+
output_dir,
36+
],
37+
justify="start",
38+
),
39+
mo.hstack(
40+
[mo.md("### Filter data to applet_name: "), filter_to_applet_name],
41+
justify="start",
42+
),
43+
mo.md(f"Current dir: {os.getcwd()}"),
44+
run_button,
2645
]
2746
)
28-
return (output_dir,)
29-
30-
31-
@app.cell(hide_code=True)
32-
def _(mo):
33-
participants_file = mo.ui.file()
34-
mo.vstack([mo.md("## Upload participants file"), participants_file])
35-
return (participants_file,)
47+
return (
48+
data_file,
49+
filter_to_applet_name,
50+
output_dir,
51+
participants_file,
52+
run_button,
53+
)
3654

3755

38-
@app.cell(hide_code=True)
56+
@app.cell
3957
def _(OutputGenerationError, cs, mo, participants_file, pl, run_button):
4058
def load_participants(data) -> pl.DataFrame:
4159
"""Load participants from file path in extra args."""
@@ -63,22 +81,8 @@ def load_participants(data) -> pl.DataFrame:
6381
return (participants_data,)
6482

6583

66-
@app.cell(hide_code=True)
67-
def _(mo):
68-
data_file = mo.ui.file()
69-
mo.vstack([mo.md("## Upload data file"), data_file])
70-
return (data_file,)
71-
72-
73-
@app.cell(hide_code=True)
74-
def _(mo):
75-
run_button = mo.ui.run_button()
76-
run_button
77-
return (run_button,)
78-
79-
80-
@app.cell(hide_code=True)
81-
def _(data_file, mo, pl, run_button):
84+
@app.cell
85+
def _(data_file, filter_to_applet_name, mo, pl, run_button):
8286
def load_data(mindlogger_data) -> pl.DataFrame:
8387
"""Load data."""
8488
return (
@@ -87,6 +91,7 @@ def load_data(mindlogger_data) -> pl.DataFrame:
8791
# try_parse_dates=True,
8892
# schema_overrides={"response_start_time": pl.Datetime()},
8993
)
94+
.filter(pl.col("applet_name") == filter_to_applet_name.value)
9095
.select(
9196
pl.col("activity_name"),
9297
pl.col("secret_user_id").alias("secret_id"),

0 commit comments

Comments
 (0)