mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 05:55:42 +09:00
new(database column): add slavelog validity to single & extra run results
This commit is contained in:
parent
7758e5e0d6
commit
559f0e5ce7
5 changed files with 120 additions and 57 deletions
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- QAQC progress plot notebook
|
- QAQC progress plot notebook
|
||||||
- (notebook) PLLLD wait time scan
|
- (notebook) PLLLD wait time scan
|
||||||
- Added QAQC campaign 7 to the database
|
- Added QAQC campaign 7 to the database
|
||||||
|
- Added slave log validity columns to single and extra run result tables (!1418)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ function create_database_from_exported_csvs(
|
||||||
add_qaqc_single_result(db, single_result_df, runlist_table)
|
add_qaqc_single_result(db, single_result_df, runlist_table)
|
||||||
add_qaqc_dispatch(db, dispatch_table)
|
add_qaqc_dispatch(db, dispatch_table)
|
||||||
add_qaqc_runlist_from_masterlogs(db, masterlog_dir)
|
add_qaqc_runlist_from_masterlogs(db, masterlog_dir)
|
||||||
add_qaqc_100test_result(db, extra_100test_result_df)
|
add_qaqc_100test_result(db, extra_100test_result_df, slavelog_dir)
|
||||||
add_skew_from_slave_clk_logs(db, slavelog_dir)
|
add_skew_from_slave_clk_logs(db, slavelog_dir)
|
||||||
add_slavelog_result(db, slavelog_dir)
|
add_slavelog_result(db, slavelog_dir)
|
||||||
|
|
||||||
|
|
|
@ -608,15 +608,20 @@ function get_num_tests_for_extra_runs(runid::Int64)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
add_qaqc_100test_result(db::SQLite.DB, table::DataFrame) -> nothing
|
add_qaqc_100test_result(db::SQLite.DB, table::DataFrame, logs_dir::AbstractString) -> nothing
|
||||||
|
|
||||||
Fill `qaqc_extra_run_results` table in `db` from `table` DataFrame,
|
Fill `qaqc_extra_run_results` table in `db` from `table` DataFrame,
|
||||||
which is converted from a raw exported CSV.
|
which is converted from a raw exported CSV.
|
||||||
|
|
||||||
|
# Args
|
||||||
|
|
||||||
|
- `table`: 100 test result table, prepared with [`prepare_100test_table`](@ref)
|
||||||
|
- `logs_dir`: where slave log files located in certain format
|
||||||
|
|
||||||
# Detail
|
# Detail
|
||||||
- skips psboards in `resistance_test_passed` with `passed == false`
|
- skips psboards in `resistance_test_passed` with `passed == false`
|
||||||
"""
|
"""
|
||||||
function add_qaqc_100test_result(db::SQLite.DB, table::DataFrame)
|
function add_qaqc_100test_result(db::SQLite.DB, table::DataFrame, logs_dir::AbstractString)
|
||||||
position_id_map =
|
position_id_map =
|
||||||
["B-$i-$j" for i in 0:1 for j in 1:9] |> enumerate .|> (x -> begin
|
["B-$i-$j" for i in 0:1 for j in 1:9] |> enumerate .|> (x -> begin
|
||||||
(i, s) = x
|
(i, s) = x
|
||||||
|
@ -625,22 +630,25 @@ function add_qaqc_100test_result(db::SQLite.DB, table::DataFrame)
|
||||||
|
|
||||||
table = prepare_100test_table(table)
|
table = prepare_100test_table(table)
|
||||||
|
|
||||||
stmt_search_runid = DBInterface.prepare(
|
qaqc_run_ids =
|
||||||
db,
|
DBInterface.execute(
|
||||||
sql"""
|
db,
|
||||||
SELECT id
|
sql"""
|
||||||
FROM qaqc_runs
|
SELECT id
|
||||||
WHERE id = :runid
|
FROM qaqc_runs
|
||||||
""",
|
""",
|
||||||
)
|
) |> Tables.columntable |> (t -> t.id)
|
||||||
stmt_search_resistance_error = DBInterface.prepare(
|
resistance_error_psb_list =
|
||||||
db,
|
DBInterface.execute(
|
||||||
sql"""
|
db,
|
||||||
SELECT psb_id
|
sql"""
|
||||||
FROM qaqc_resistance_check
|
SELECT psb_id
|
||||||
WHERE psb_id = :psboard_id AND passed = 0
|
FROM qaqc_resistance_check
|
||||||
""",
|
WHERE passed = 0
|
||||||
)
|
""",
|
||||||
|
) |>
|
||||||
|
Tables.columntable |>
|
||||||
|
(t -> t.psb_id)
|
||||||
stmt_insert_result = DBInterface.prepare(
|
stmt_insert_result = DBInterface.prepare(
|
||||||
db,
|
db,
|
||||||
sql"""
|
sql"""
|
||||||
|
@ -662,7 +670,8 @@ function add_qaqc_100test_result(db::SQLite.DB, table::DataFrame)
|
||||||
bcid_fail,
|
bcid_fail,
|
||||||
invalid_register_value,
|
invalid_register_value,
|
||||||
power_out_of_range,
|
power_out_of_range,
|
||||||
note
|
note,
|
||||||
|
is_slavelog_valid
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
:runid,
|
:runid,
|
||||||
|
@ -681,47 +690,61 @@ function add_qaqc_100test_result(db::SQLite.DB, table::DataFrame)
|
||||||
:bcid_fail,
|
:bcid_fail,
|
||||||
:invalid_register_value,
|
:invalid_register_value,
|
||||||
:power_out_of_range,
|
:power_out_of_range,
|
||||||
:note
|
:note,
|
||||||
|
:is_slavelog_valid
|
||||||
)
|
)
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
lock_db = ReentrantLock()
|
||||||
|
|
||||||
for row in eachrow(table)
|
Threads.@threads for row in eachrow(table)
|
||||||
if DBInterface.execute(stmt_search_runid, (; runid = row.runid)) |> isempty
|
if ismissing(row.runid) || !(row.runid in qaqc_run_ids)
|
||||||
# search for resistance error
|
# search for resistance error
|
||||||
if !isempty(
|
if row.motherboard_id in resistance_error_psb_list
|
||||||
DBInterface.execute(
|
|
||||||
stmt_search_resistance_error,
|
|
||||||
(; psboard_id = row.motherboard_id),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
error("Runid $(row.runid) not found in `qaqc_runs` table.")
|
error("Runid $(row.runid) not found in `qaqc_runs` table.")
|
||||||
end
|
end
|
||||||
|
|
||||||
DBInterface.execute(
|
is_slavelog_valid = try
|
||||||
stmt_insert_result,
|
SlaveLogParser.parse_slavelog_file(
|
||||||
(
|
joinpath(
|
||||||
runid = row.runid,
|
logs_dir,
|
||||||
psboard_id = row.motherboard_id,
|
"main",
|
||||||
position = position_id_map[row.position],
|
"$(row.motherboard_id)_$(row.runid)_longrun.txt",
|
||||||
num_tests = get_num_tests_for_extra_runs(row.runid),
|
),
|
||||||
insufficient_reset_with_10 = row.var"10回reset足りず",
|
)
|
||||||
reset_failed_though_reconfig_done = row.var"reconfig_done = 0なのにresetしていない",
|
true
|
||||||
always_hit_flag_true = row.var"always_hit_flag",
|
catch e
|
||||||
dac_is_0 = row.var"DAC = 0",
|
@debug "Failed to parse slave log due to $(e)" catch_backtrace()
|
||||||
bcid_shift = row.var"DAC = 0",
|
false
|
||||||
efficiency_99percent = row.var"efficiency 99%",
|
end
|
||||||
bcid_fail_111 = row.var"BCID 0:0:0",
|
|
||||||
bcid_fail_000 = row.var"BCID 1:1:1",
|
lock(lock_db) do
|
||||||
low_efficiency = row.var"low efficiency",
|
DBInterface.execute(
|
||||||
bcid_fail = row.var"BCID fail",
|
stmt_insert_result,
|
||||||
invalid_register_value = row.var"invalid register values",
|
(
|
||||||
power_out_of_range = row.var"power out of range",
|
runid = row.runid,
|
||||||
note = row.Column20,
|
psboard_id = row.motherboard_id,
|
||||||
),
|
position = position_id_map[row.position],
|
||||||
)
|
num_tests = get_num_tests_for_extra_runs(row.runid),
|
||||||
|
insufficient_reset_with_10 = row.var"10回reset足りず",
|
||||||
|
reset_failed_though_reconfig_done = row.var"reconfig_done = 0なのにresetしていない",
|
||||||
|
always_hit_flag_true = row.var"always_hit_flag",
|
||||||
|
dac_is_0 = row.var"DAC = 0",
|
||||||
|
bcid_shift = row.var"DAC = 0",
|
||||||
|
efficiency_99percent = row.var"efficiency 99%",
|
||||||
|
bcid_fail_111 = row.var"BCID 0:0:0",
|
||||||
|
bcid_fail_000 = row.var"BCID 1:1:1",
|
||||||
|
low_efficiency = row.var"low efficiency",
|
||||||
|
bcid_fail = row.var"BCID fail",
|
||||||
|
invalid_register_value = row.var"invalid register values",
|
||||||
|
power_out_of_range = row.var"power out of range",
|
||||||
|
note = row.Column20,
|
||||||
|
is_slavelog_valid,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nothing
|
nothing
|
||||||
|
@ -742,7 +765,7 @@ function add_skew_from_slave_clk_logs(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
db,
|
db,
|
||||||
sql"""
|
sql"""
|
||||||
UPDATE qaqc_single_run_results
|
UPDATE qaqc_single_run_results
|
||||||
SET lvds_tx_skew = :skew
|
SET lvds_tx_skew = :skew, is_slaveclocklog_valid = :is_slaveclocklog_valid
|
||||||
WHERE runid = :runid AND psboard_id = :psbid
|
WHERE runid = :runid AND psboard_id = :psbid
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
@ -760,9 +783,27 @@ function add_skew_from_slave_clk_logs(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
|
|
||||||
if m[:psbid] == "630" && m[:runid] == "190"
|
if m[:psbid] == "630" && m[:runid] == "190"
|
||||||
@debug "skipping... (psbid=630 runid=190 is broken)"
|
@debug "skipping... (psbid=630 runid=190 is broken)"
|
||||||
|
DBInterface.execute(
|
||||||
|
stmt_insert_skew_to_single_result,
|
||||||
|
(
|
||||||
|
skew = missing,
|
||||||
|
is_slaveclocklog_valid = false,
|
||||||
|
runid = m[:runid],
|
||||||
|
psbid = m[:psbid],
|
||||||
|
),
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
elseif m[:psbid] == "627" && m[:runid] == "344"
|
elseif m[:psbid] == "627" && m[:runid] == "344"
|
||||||
@debug "skipping... (psbid=627 runid=344 is broken)"
|
@debug "skipping... (psbid=627 runid=344 is broken)"
|
||||||
|
DBInterface.execute(
|
||||||
|
stmt_insert_skew_to_single_result,
|
||||||
|
(
|
||||||
|
skew = missing,
|
||||||
|
is_slaveclocklog_valid = false,
|
||||||
|
runid = m[:runid],
|
||||||
|
psbid = m[:psbid],
|
||||||
|
),
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -775,7 +816,12 @@ function add_skew_from_slave_clk_logs(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
|
|
||||||
DBInterface.execute(
|
DBInterface.execute(
|
||||||
stmt_insert_skew_to_single_result,
|
stmt_insert_skew_to_single_result,
|
||||||
(skew = ClockParser.get_skew(file), runid = m[:runid], psbid = m[:psbid]),
|
(
|
||||||
|
skew = ClockParser.get_skew(file),
|
||||||
|
is_slaveclocklog_valid = true,
|
||||||
|
runid = m[:runid],
|
||||||
|
psbid = m[:psbid],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -793,8 +839,8 @@ function add_slavelog_result(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
exclude_runs = (
|
exclude_runs = (
|
||||||
(runid = 51, psbid = nothing, reason = "clock only"),
|
(runid = 51, psbid = nothing, reason = "clock only"),
|
||||||
(runid = 175, psbid = nothing, reason = "broken files"),
|
(runid = 175, psbid = nothing, reason = "broken files"),
|
||||||
(runid = 437, psbid = 1215, reason = "PSBID 1215 is not completed"),
|
(runid = 437, psbid = 1215, reason = "PSBID 1215 is not completed"), # debug 6.5
|
||||||
(runid = 439, psbid = 703, reason = "PSBID 703 is not completed"),
|
(runid = 439, psbid = 703, reason = "PSBID 703 is not completed"), # debug 6.5
|
||||||
(runid = 434, psbid = 723, reason = "PSBID 723 is not completed"),
|
(runid = 434, psbid = 723, reason = "PSBID 723 is not completed"),
|
||||||
)
|
)
|
||||||
@assert eltype(exclude_runs) != Any
|
@assert eltype(exclude_runs) != Any
|
||||||
|
@ -806,7 +852,8 @@ function add_slavelog_result(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
SET
|
SET
|
||||||
power_3v3d = :power_3v3d,
|
power_3v3d = :power_3v3d,
|
||||||
power_3v3a = :power_3v3a,
|
power_3v3a = :power_3v3a,
|
||||||
power_n3va = :power_n3va
|
power_n3va = :power_n3va,
|
||||||
|
is_slavelog_valid = :is_slavelog_valid
|
||||||
WHERE
|
WHERE
|
||||||
runid = :runid AND psboard_id = :psbid
|
runid = :runid AND psboard_id = :psbid
|
||||||
""",
|
""",
|
||||||
|
@ -839,6 +886,17 @@ function add_slavelog_result(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
end
|
end
|
||||||
if !isempty(exclude_cond)
|
if !isempty(exclude_cond)
|
||||||
@debug "skipping runid = $(runid) for $(first(exclude_cond).reason)"
|
@debug "skipping runid = $(runid) for $(first(exclude_cond).reason)"
|
||||||
|
DBInterface.execute(
|
||||||
|
stmt_insert_slave_result_to_single_result,
|
||||||
|
(;
|
||||||
|
power_3v3d = missing,
|
||||||
|
power_3v3a = missing,
|
||||||
|
power_n3va = missing,
|
||||||
|
is_slavelog_valid = false,
|
||||||
|
runid,
|
||||||
|
psbid,
|
||||||
|
),
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -864,6 +922,7 @@ function add_slavelog_result(db::SQLite.DB, logs_dir::AbstractString)
|
||||||
power_3v3d = slave_result.power[1].result_3v3d,
|
power_3v3d = slave_result.power[1].result_3v3d,
|
||||||
power_3v3a = slave_result.power[1].result_3v3a,
|
power_3v3a = slave_result.power[1].result_3v3a,
|
||||||
power_n3va = slave_result.power[1].result_n3va,
|
power_n3va = slave_result.power[1].result_n3va,
|
||||||
|
is_slavelog_valid = true,
|
||||||
runid,
|
runid,
|
||||||
psbid,
|
psbid,
|
||||||
),
|
),
|
||||||
|
|
|
@ -26,6 +26,8 @@ CREATE TABLE qaqc_single_run_results (
|
||||||
power_3v3a REAL,
|
power_3v3a REAL,
|
||||||
power_n3va REAL,
|
power_n3va REAL,
|
||||||
note TEXT,
|
note TEXT,
|
||||||
|
is_slavelog_valid BOOLEAN,
|
||||||
|
is_slaveclocklog_valid BOOLEAN,
|
||||||
FOREIGN KEY("runid") REFERENCES "qaqc_runs"("id"),
|
FOREIGN KEY("runid") REFERENCES "qaqc_runs"("id"),
|
||||||
FOREIGN KEY("psboard_id") REFERENCES "ps_boards"("id"),
|
FOREIGN KEY("psboard_id") REFERENCES "ps_boards"("id"),
|
||||||
FOREIGN KEY("position") REFERENCES "qaqc_positions"("id")
|
FOREIGN KEY("position") REFERENCES "qaqc_positions"("id")
|
||||||
|
@ -86,6 +88,7 @@ CREATE TABLE qaqc_extra_run_results (
|
||||||
invalid_register_value INTEGER,
|
invalid_register_value INTEGER,
|
||||||
power_out_of_range INTEGER,
|
power_out_of_range INTEGER,
|
||||||
note TEXT,
|
note TEXT,
|
||||||
|
is_slavelog_valid BOOLEAN,
|
||||||
FOREIGN KEY("runid") REFERENCES "qaqc_runs"("id"),
|
FOREIGN KEY("runid") REFERENCES "qaqc_runs"("id"),
|
||||||
FOREIGN KEY("psboard_id") REFERENCES "ps_boards"("id"),
|
FOREIGN KEY("psboard_id") REFERENCES "ps_boards"("id"),
|
||||||
FOREIGN KEY("position") REFERENCES "qaqc_positions"("id")
|
FOREIGN KEY("position") REFERENCES "qaqc_positions"("id")
|
||||||
|
|
|
@ -243,7 +243,7 @@ true || include("../src/PSBoardDataBase.jl")
|
||||||
extra_100test_result_df =
|
extra_100test_result_df =
|
||||||
CSV.read(PSBoardDataBase.DownloadCSVs.download_hundred_run_csv(), DataFrame)
|
CSV.read(PSBoardDataBase.DownloadCSVs.download_hundred_run_csv(), DataFrame)
|
||||||
|
|
||||||
@test PSBoardDataBase.add_qaqc_100test_result(db, extra_100test_result_df) |>
|
@test PSBoardDataBase.add_qaqc_100test_result(db, extra_100test_result_df, "input/slavelogs/") |>
|
||||||
isnothing
|
isnothing
|
||||||
|
|
||||||
@test PSBoardDataBase.add_skew_from_slave_clk_logs(db, "input/slavelogs/") |>
|
@test PSBoardDataBase.add_skew_from_slave_clk_logs(db, "input/slavelogs/") |>
|
||||||
|
|
Loading…
Add table
Reference in a new issue