Skip to content

Commit 210af6f

Browse files
author
David Tang
committed
fix: remove fake data
1 parent 78f5556 commit 210af6f

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

backend/ccfatigue/routers/experiments.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ async def get_tests_dashboard_plots(
8686
then we mascarade test_id field so that it looks like
8787
to be matching the one asked for.
8888
"""
89-
transposed_test_ids = [((test_id - 1) % 10) + 1 for test_id in test_ids]
9089
dashboard_plots = await generate_tests_dashboard_plots(
91-
session, 1, transposed_test_ids
90+
session, experiment_id, test_ids
9291
)
93-
for i in range(len(test_ids)):
94-
dashboard_plots.tests[i].test_id = test_ids[i]
9592
return dashboard_plots
9693

9794

backend/ccfatigue/utils/bokeh_plots.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,20 @@ def get_dataframe(
106106
"""
107107
return extracted DataFrame related to that test from CSV
108108
"""
109-
filename = f"measure_{specimen_id:03d}.csv"
110109
# FIXME researcher_name from a column value
111110
researcher_name = exp["researcher"].split(" ")[-1]
112-
filepath = os.path.join(
113-
DATA_DIRECTORY,
114-
f"{data_in}_{researcher_name}_{exp['date']}_{exp['experiment_type']}",
115-
filename,
116-
)
111+
if data_in == "HYS":
112+
filepath = os.path.join(
113+
DATA_DIRECTORY,
114+
f"TST_{researcher_name}_{exp['date']}_{exp['experiment_type']}",
115+
f"{data_in}_measure_{specimen_id:03d}.csv",
116+
)
117+
else:
118+
filepath = os.path.join(
119+
DATA_DIRECTORY,
120+
f"{data_in}_{researcher_name}_{exp['date']}_{exp['experiment_type']}",
121+
f"measure_{specimen_id:03d}.csv",
122+
)
117123
abspath = os.path.abspath(filepath)
118124
print(abspath)
119125
return pd.read_csv(abspath)
@@ -314,31 +320,31 @@ async def generate_tests_dashboard_plots(
314320
Generate 4 plots displayed in the Tests Dashboard view
315321
"""
316322
colors = list(palettes.Category10_10)[: len(test_ids)]
317-
exp = dict(
318-
zip(
319-
("laboratory", "researcher", "experiment_type", "date"),
320-
list(
321-
await session.execute(
322-
select(
323-
Experiment.laboratory,
324-
Experiment.researcher,
325-
Experiment.experiment_type,
326-
Experiment.date,
327-
).where(Experiment.id == experiment_id)
328-
) # type: ignore
329-
)[0],
323+
exp = (
324+
(
325+
await session.execute(
326+
select(
327+
Experiment.laboratory,
328+
Experiment.researcher,
329+
Experiment.experiment_type,
330+
Experiment.date,
331+
).where(Experiment.id == experiment_id)
332+
)
330333
)
334+
.one()
335+
._asdict()
331336
)
332-
# TODO only one sql request
333-
specimen_ids = []
334-
for test_id in test_ids:
335-
specimen_ids.append(
336-
await session.scalar(
337-
select(Test.specimen_number)
337+
tests = {
338+
value[0]: value[1]
339+
for value in (
340+
await session.execute(
341+
select(Test.id, Test.specimen_number)
338342
.where(Test.experiment_id == experiment_id)
339-
.where(Test.id == test_id)
343+
.where(Test.id.in_(test_ids))
340344
)
341-
)
345+
).all()
346+
}
347+
specimen_ids = [tests[test_id] for test_id in test_ids]
342348
std_dfs = [get_dataframe("TST", exp, specimen_id) for specimen_id in specimen_ids]
343349
hyst_dfs = [get_dataframe("HYS", exp, specimen_id) for specimen_id in specimen_ids]
344350
tests = [

backend/init_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
DATA_DIR = os.path.abspath(f"{__file__}/../../Data/preprocessed")
2222
# EXPERIMENTS_TO_INJECT = glob.glob(f"{DATA_DIR}/TST_*")
2323
EXPERIMENTS_TO_INJECT = [ # TODO !
24-
DATA_DIR + "/TST_Wang_2020-12_QS",
24+
DATA_DIR + "/TST_Liu_2020-09_FA",
2525
]
2626
print(f"{EXPERIMENTS_TO_INJECT=}")
2727

0 commit comments

Comments
 (0)