Skip to content

Commit a78ba1f

Browse files
fix: persist result server metadata for estimation [code:qws] [system:RC_GH200]
1 parent cc9a676 commit a78ba1f

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

scripts/estimate_common.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ read_values() {
102102
est_uuid=$(jq -r '._server_uuid // empty' "$json_file")
103103
est_timestamp=$(jq -r '._server_timestamp // empty' "$json_file")
104104

105+
# Fallback: read send_results manifest if the result JSON itself does not
106+
# carry the server-assigned metadata.
107+
if [[ -z "$est_uuid" || -z "$est_timestamp" ]]; then
108+
local meta_file
109+
local basename
110+
meta_file="$(dirname "$json_file")/result_server_meta.json"
111+
basename=$(basename "$json_file")
112+
if [[ -f "$meta_file" ]]; then
113+
if [[ -z "$est_uuid" ]]; then
114+
est_uuid=$(jq -r --arg file "$basename" '.[$file].uuid // empty' "$meta_file")
115+
fi
116+
if [[ -z "$est_timestamp" ]]; then
117+
est_timestamp=$(jq -r --arg file "$basename" '.[$file].timestamp // empty' "$meta_file")
118+
fi
119+
fi
120+
fi
121+
105122
# Fallback: extract from filename if not in JSON
106123
if [[ -z "$est_uuid" || -z "$est_timestamp" ]]; then
107124
local basename

scripts/run_estimate.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ found=0
2323
for json_file in results/result*.json; do
2424
[[ ! -f "$json_file" ]] && continue
2525
found=1
26+
echo "Input result metadata for $json_file:"
27+
jq '{code, system, Exp, _server_uuid, _server_timestamp}' "$json_file" || true
28+
if [[ -f results/result_server_meta.json ]]; then
29+
echo "Available result metadata manifest:"
30+
jq . results/result_server_meta.json || true
31+
fi
2632
echo "Running estimation: $estimate_script $json_file"
2733
bash "$estimate_script" "$json_file"
2834
done

scripts/send_results.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ echo "Sending results to server"
55

66
ls results/
77

8+
meta_file="results/result_server_meta.json"
9+
echo "{}" > "$meta_file"
10+
811
# Loop over all result*.json files
912
for json_file in results/result*.json; do
1013
[[ ! -f "$json_file" ]] && continue
@@ -51,6 +54,20 @@ with open('${tmp_file}', 'w') as f:
5154
" && mv "$tmp_file" "$json_file"
5255
echo "Wrote _server_uuid and _server_timestamp back to $json_file"
5356

57+
tmp_meta_file="${meta_file}.tmp"
58+
python3 -c "
59+
import json
60+
with open('${meta_file}', 'r') as f:
61+
d = json.load(f)
62+
d['$(basename "$json_file")'] = {
63+
'uuid': '${uuid}',
64+
'timestamp': '${timestamp}'
65+
}
66+
with open('${tmp_meta_file}', 'w') as f:
67+
json.dump(d, f, indent=2)
68+
" && mv "$tmp_meta_file" "$meta_file"
69+
echo "Updated result metadata manifest: $meta_file"
70+
5471
# Determine corresponding TGZ name
5572
tgz_base="padata"
5673

0 commit comments

Comments
 (0)