File tree Expand file tree Collapse file tree
tests/unit/agentplatform/genai Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1155,7 +1155,7 @@ def get_comparison_html(eval_result_json: str) -> str:
11551155 winRateText = m.win_rates.map((rate, i) => `<b>${{candidateNames ? candidateNames[i] : `Candidate #${{i+1}}`}}</b> wins: <b>${{(rate * 100).toFixed(1)}}%</b>`).join('<br>');
11561156 if (m.tie_rate !== undefined) {{ winRateText += `<br>Ties: <b>${{(m.tie_rate * 100).toFixed(1)}}%</b>`; }}
11571157 }}
1158- table += `<tr><td>${{m.metric_name}}</td><td>${{m.mean_score. toFixed(4)}}</td><td>${{m.stdev_score. toFixed(4)}}</td><td>${{winRateText}}</td></tr>`;
1158+ table += `<tr><td>${{m.metric_name}}</td><td>${{m.mean_score != null ? m.mean_score. toFixed(4) : 'N/A' }}</td><td>${{m.stdev_score != null ? m.stdev_score. toFixed(4) : 'N/A' }}</td><td>${{winRateText}}</td></tr>`;
11591159 }});
11601160 container.innerHTML = table + '</tbody></table>';
11611161 }}
Original file line number Diff line number Diff line change @@ -822,6 +822,16 @@ def test_get_comparison_html(self):
822822 assert payload_b64 in html
823823 assert "DOMPurify" in html
824824
825+ def test_get_comparison_html_shows_na_for_missing_summary_scores(self):
826+ from vertexai._genai import (
827+ _evals_visualization as vertexai_evals_visualization,
828+ )
829+
830+ for viz in (_evals_visualization, vertexai_evals_visualization):
831+ html = viz.get_comparison_html("{}")
832+ assert "m.mean_score != null ? m.mean_score.toFixed(4) : 'N/A'" in html
833+ assert "m.stdev_score != null ? m.stdev_score.toFixed(4) : 'N/A'" in html
834+
825835 def test_get_inference_html(self):
826836 """Tests that get_inference_html generates valid HTML with data."""
827837 from agentplatform._genai import _evals_visualization
Original file line number Diff line number Diff line change @@ -1111,7 +1111,7 @@ def get_comparison_html(eval_result_json: str) -> str:
11111111 winRateText = m.win_rates.map((rate, i) => `<b>${{candidateNames ? candidateNames[i] : `Candidate #${{i+1}}`}}</b> wins: <b>${{(rate * 100).toFixed(1)}}%</b>`).join('<br>');
11121112 if (m.tie_rate !== undefined) {{ winRateText += `<br>Ties: <b>${{(m.tie_rate * 100).toFixed(1)}}%</b>`; }}
11131113 }}
1114- table += `<tr><td>${{m.metric_name}}</td><td>${{m.mean_score. toFixed(4)}}</td><td>${{m.stdev_score. toFixed(4)}}</td><td>${{winRateText}}</td></tr>`;
1114+ table += `<tr><td>${{m.metric_name}}</td><td>${{m.mean_score != null ? m.mean_score. toFixed(4) : 'N/A' }}</td><td>${{m.stdev_score != null ? m.stdev_score. toFixed(4) : 'N/A' }}</td><td>${{winRateText}}</td></tr>`;
11151115 }});
11161116 container.innerHTML = table + '</tbody></table>';
11171117 }}
You can’t perform that action at this time.
0 commit comments