fix for archive free fall leak test
This commit is contained in:
parent
a03a5e6186
commit
14f7a8cda6
@ -825,30 +825,60 @@ class Test(Widget):
|
|||||||
# Remove useless info
|
# Remove useless info
|
||||||
self.data.get("recipe", {}).get("spec", {}).pop("steps", None)
|
self.data.get("recipe", {}).get("spec", {}).pop("steps", None)
|
||||||
|
|
||||||
for leak in ["leak_1", "leak_2"]:
|
# Consolidate and preserve leak results for saving; include also free-fall leak if present
|
||||||
if leak in self.data.keys() and "results" in self.data[leak]:
|
for leak in ["test_freefall_leak", "leak_1", "leak_2"]:
|
||||||
# Check if tester_component exists in results
|
if leak in self.data and isinstance(self.data[leak], dict) and "results" in self.data[leak]:
|
||||||
if self.tester_component in self.data[leak]["results"]:
|
leak_container = self.data[leak]
|
||||||
# Safely extract results with necessary checks
|
raw_results = leak_container.get("results", {})
|
||||||
results = {k: self.data[leak]["results"][self.tester_component].get(k, "N/A")
|
|
||||||
for k in ["Running test: result"]}
|
# Try to find the dictionary that contains the "Running test:" keys
|
||||||
results.update(
|
device_results = {}
|
||||||
{
|
if isinstance(raw_results, dict):
|
||||||
k: round(float(self.data[leak]["results"][self.tester_component].get(k, 0.0)), 2)
|
# 1) Preferred: nested under tester_component key
|
||||||
for k in [
|
if self.tester_component and self.tester_component in raw_results and isinstance(raw_results[self.tester_component], dict):
|
||||||
"Running test: filling pressure",
|
device_results = raw_results[self.tester_component]
|
||||||
"Running test: measured leak",
|
else:
|
||||||
"Running test: pressure at the end of settling",
|
# 2) Fallback: scan top-level values to find a dict with expected keys
|
||||||
]
|
for v in raw_results.values():
|
||||||
}
|
if isinstance(v, dict) and any(k.startswith("Running test:") for k in v.keys()):
|
||||||
)
|
device_results = v
|
||||||
self.data[leak]["results"] = results
|
break
|
||||||
else:
|
# 3) As a last resort, maybe the keys are already at this level
|
||||||
self.log.warning(
|
if not device_results and any(k.startswith("Running test:") for k in raw_results.keys()):
|
||||||
f"Missing tester_component '{self.tester_component}' in leak results for '{leak}', skipping...")
|
device_results = raw_results
|
||||||
self.data[leak]["results"] = {"Running test: result": "MISSING"}
|
|
||||||
else:
|
# Build a compact, consistent summary while preserving raw data
|
||||||
self.log.warning(f"Leak '{leak}' has no results; skipping...")
|
summary = {}
|
||||||
|
# Preserve textual result (if any)
|
||||||
|
if isinstance(device_results, dict):
|
||||||
|
summary["Running test: result"] = device_results.get("Running test: result", raw_results.get("Running test: result", "N/A"))
|
||||||
|
# Numeric metrics (rounded)
|
||||||
|
for k in [
|
||||||
|
"Running test: filling pressure",
|
||||||
|
"Running test: measured leak",
|
||||||
|
"Running test: pressure at the end of settling",
|
||||||
|
]:
|
||||||
|
try:
|
||||||
|
v = device_results.get(k, raw_results.get(k, None))
|
||||||
|
if v is not None:
|
||||||
|
summary[k] = round(float(v), 2)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Derive pressure at end of measure if possible
|
||||||
|
try:
|
||||||
|
if "Running test: pressure at the end of settling" in summary and "Running test: measured leak" in summary:
|
||||||
|
summary["Running test: pressure at the end of measure"] = round(
|
||||||
|
float(summary["Running test: pressure at the end of settling"]) + float(summary["Running test: measured leak"]), 2
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Attach the cleaned summary, but keep the raw results for traceability
|
||||||
|
leak_container["raw_results"] = raw_results
|
||||||
|
leak_container["results"] = summary
|
||||||
|
elif leak in self.data:
|
||||||
|
self.log.warning(f"Leak step '{leak}' has no results; skipping consolidation...")
|
||||||
|
|
||||||
if "vision" in self.data:
|
if "vision" in self.data:
|
||||||
vision = self.data.get("vision", {})
|
vision = self.data.get("vision", {})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user