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
|
||||
self.data.get("recipe", {}).get("spec", {}).pop("steps", None)
|
||||
|
||||
for leak in ["leak_1", "leak_2"]:
|
||||
if leak in self.data.keys() and "results" in self.data[leak]:
|
||||
# Check if tester_component exists in results
|
||||
if self.tester_component in self.data[leak]["results"]:
|
||||
# Safely extract results with necessary checks
|
||||
results = {k: self.data[leak]["results"][self.tester_component].get(k, "N/A")
|
||||
for k in ["Running test: result"]}
|
||||
results.update(
|
||||
{
|
||||
k: round(float(self.data[leak]["results"][self.tester_component].get(k, 0.0)), 2)
|
||||
for k in [
|
||||
"Running test: filling pressure",
|
||||
"Running test: measured leak",
|
||||
"Running test: pressure at the end of settling",
|
||||
]
|
||||
}
|
||||
)
|
||||
self.data[leak]["results"] = results
|
||||
else:
|
||||
self.log.warning(
|
||||
f"Missing tester_component '{self.tester_component}' in leak results for '{leak}', skipping...")
|
||||
self.data[leak]["results"] = {"Running test: result": "MISSING"}
|
||||
else:
|
||||
self.log.warning(f"Leak '{leak}' has no results; skipping...")
|
||||
# Consolidate and preserve leak results for saving; include also free-fall leak if present
|
||||
for leak in ["test_freefall_leak", "leak_1", "leak_2"]:
|
||||
if leak in self.data and isinstance(self.data[leak], dict) and "results" in self.data[leak]:
|
||||
leak_container = self.data[leak]
|
||||
raw_results = leak_container.get("results", {})
|
||||
|
||||
# Try to find the dictionary that contains the "Running test:" keys
|
||||
device_results = {}
|
||||
if isinstance(raw_results, dict):
|
||||
# 1) Preferred: nested under tester_component key
|
||||
if self.tester_component and self.tester_component in raw_results and isinstance(raw_results[self.tester_component], dict):
|
||||
device_results = raw_results[self.tester_component]
|
||||
else:
|
||||
# 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
|
||||
break
|
||||
# 3) As a last resort, maybe the keys are already at this level
|
||||
if not device_results and any(k.startswith("Running test:") for k in raw_results.keys()):
|
||||
device_results = raw_results
|
||||
|
||||
# Build a compact, consistent summary while preserving raw data
|
||||
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:
|
||||
vision = self.data.get("vision", {})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user