Skip to content

Commit 1ba0a70

Browse files
feat: record re-estimation context metadata [code:qws] [system:MiyabiG]
1 parent d548f25 commit 1ba0a70

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

scripts/estimation/common.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ est_model_json=""
7878
est_applicability_json=""
7979
est_confidence_json=""
8080
est_notes_json=""
81+
est_reestimation_json=""
8182

8283
_bk_normalize_estimation_timestamp() {
8384
local raw="${1:-}"
@@ -95,6 +96,17 @@ _bk_normalize_estimation_timestamp() {
9596
echo "$raw"
9697
}
9798

99+
load_reestimation_context() {
100+
local context_file="results/reestimation_context.json"
101+
102+
if [[ ! -f "$context_file" ]]; then
103+
est_reestimation_json=""
104+
return 0
105+
fi
106+
107+
est_reestimation_json=$(jq -c '.' "$context_file")
108+
}
109+
98110
# ---------------------------------------------------------------------------
99111
# read_values — Read benchmark Result_JSON into global variables
100112
#
@@ -173,6 +185,8 @@ read_values() {
173185
# for the estimation result. Package-aware estimation scripts may override
174186
# this explicitly when needed.
175187
est_source_result_uuid="$est_uuid"
188+
189+
load_reestimation_context
176190
}
177191

178192
# ---------------------------------------------------------------------------
@@ -229,6 +243,7 @@ bk_estimation_reset_output_state() {
229243
est_model_json=""
230244
est_confidence_json=""
231245
est_notes_json=""
246+
est_reestimation_json=""
232247
}
233248

234249
# ---------------------------------------------------------------------------
@@ -504,6 +519,12 @@ print_json() {
504519
\"notes\": $est_notes_json"
505520
fi
506521

522+
local reestimation_block=""
523+
if [[ -n "$est_reestimation_json" && "$est_reestimation_json" != "null" ]]; then
524+
reestimation_block=",
525+
\"reestimation\": $est_reestimation_json"
526+
fi
527+
507528
cat <<EOF
508529
{
509530
"code": "$est_code",
@@ -536,7 +557,7 @@ print_json() {
536557
"uuid": "$est_future_bench_uuid"
537558
}${future_breakdown_block}${future_model_block}
538559
},
539-
"performance_ratio": $ratio${estimate_metadata_block}${measurement_block}${assumptions_block}${input_artifacts_block}${model_block}${applicability_block}${confidence_block}${notes_block}
560+
"performance_ratio": $ratio${estimate_metadata_block}${measurement_block}${assumptions_block}${input_artifacts_block}${model_block}${applicability_block}${confidence_block}${notes_block}${reestimation_block}
540561
}
541562
EOF
542563
}

scripts/estimation/generate_reestimate_pipeline.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# estimate_result_uuid - UUID of the estimate result to re-estimate from
1010
# estimate_uuid - legacy alias for result_uuid
1111
# code - Program code name (e.g., "qws")
12+
# Optional CI variables:
13+
# reestimation_reason - e.g. package-update, model-tuning, manual-rerun
14+
# reestimation_trigger - e.g. ci-reestimation, portal, local-test
1215
#
1316
# Output: .gitlab-ci.estimate.yml with fetch → estimate → send_estimate stages
1417

scripts/estimation/test_reestimate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ if compgen -G "results/estimate*.json" > /dev/null; then
8787
exp,
8888
performance_ratio,
8989
applicability,
90+
reestimation,
9091
estimate_metadata: {
9192
source_result_uuid,
9293
estimation_result_uuid,

scripts/result_server/fetch_result_by_uuid.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ if [[ -z "${code:-}" ]]; then
1818
fi
1919

2020
mkdir -p results
21+
rm -f results/reestimation_context.json
2122

2223
resolved_result_uuid="${result_uuid:-}"
24+
resolved_source_estimate_uuid=""
2325

2426
if [[ -z "$resolved_result_uuid" && -n "${estimate_result_uuid:-}" ]]; then
2527
echo "Fetching estimate for UUID: $estimate_result_uuid"
28+
resolved_source_estimate_uuid="$estimate_result_uuid"
2629
bk_result_server_get_json_to_file \
2730
"/api/query/estimate?uuid=${estimate_result_uuid}" \
2831
"results/source_estimate.json"
@@ -51,6 +54,23 @@ bk_result_server_get_json_to_file \
5154
"results/result0.json"
5255
echo "Fetched result to results/result0.json"
5356

57+
reestimation_reason="${reestimation_reason:-manual-rerun}"
58+
reestimation_trigger="${reestimation_trigger:-ci-reestimation}"
59+
jq -cn \
60+
--arg source_result_uuid "$resolved_result_uuid" \
61+
--arg source_estimate_result_uuid "$resolved_source_estimate_uuid" \
62+
--arg reason "$reestimation_reason" \
63+
--arg trigger "$reestimation_trigger" \
64+
'{
65+
source_result_uuid: $source_result_uuid,
66+
reason: $reason,
67+
trigger: $trigger
68+
}
69+
+ (if $source_estimate_result_uuid != "" then {source_estimate_result_uuid: $source_estimate_result_uuid} else {} end)
70+
+ (if $source_estimate_result_uuid != "" then {previous_estimation_result_uuid: $source_estimate_result_uuid} else {} end)
71+
' > results/reestimation_context.json
72+
echo "Wrote re-estimation context to results/reestimation_context.json"
73+
5474
set +e
5575
bk_result_server_download_to_file \
5676
"/api/query/estimation-inputs?uuid=${resolved_result_uuid}" \

0 commit comments

Comments
 (0)