Repository navigation
fix: GenAI Client(evals) - Scope HTML report IDs, styles, and scripts per widget in show() - #7320
Open
takumiohym wants to merge 1 commit into
Open
takumiohym wants to merge 1 commit into
takumiohym wants to merge 1 commit into
Conversation
… per widget in show()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In JupyterLab (and any notebook environment where multiple cell outputs share the same
documentDOM, unlike Google Colab which isolates each output in an<iframe>), calling.show()multiple times onEvaluationResult,EvaluationRun,EvaluationDataset, orLossAnalysisResultfails after the first report:get_evaluation_html,get_comparison_html,get_inference_html, andget_loss_analysis_htmlemit hardcoded duplicate element IDs (#summary-section,#details-section,#results-table,#loss-analysis-root) and look them up viadocument.getElementById(...)..show()call in the same notebook resolvesdocument.getElementById(...)to the first widget's containers—overwriting the first report with the latest data while leaving all subsequent reports empty below the heading.var vizData_vertex_eval_sdk/ top-level helper functions and unscopedbody/ element CSS rules also leak across cells.<script>can execute before the CDN<script src>dependencies (marked/DOMPurify) finish loading.Minimal Reproduction (JupyterLab)
Run in a JupyterLab notebook (or across two cells):
Evaluation Reportbox displaysmetric_Report 2(overwritten by the second.show()), and the secondEvaluation Reportbox renders empty below the heading.Fix
Updated both
vertexai/_genai/_evals_visualization.pyandagentplatform/_genai/_evals_visualization.py:uuid.uuid4().hex[:12]) for root containers and target divs (#summary-section-{uid},#details-section-{uid},#results-table-{uid},#loss-analysis-root-{uid}) across all 4 HTML generators (get_evaluation_html,get_comparison_html,get_inference_html,get_loss_analysis_html).(function() { ... })();) andconstbindings so scripts and globals do not collide across reports.bodystyling)._runWhenReady,_sanitize,_markedParse) so reports wait briefly forDOMPurify/markedwhen loaded asynchronously and safely escape text if the CDN scripts are unavailable.TestEvalsVisualization.test_html_reports_use_unique_ids_and_scoped_styles(parameterized acrossagentplatform._genai._evals_visualizationandvertexai._genai._evals_visualization) intests/unit/agentplatform/genai/test_evals.py.Verification
eval_result.show()calls in the same notebook (all reports render independently without overwriting earlier outputs).pytest tests/unit/agentplatform/genai/test_evals.py -k "TestLossAnalysis or TestEvalsVisualization" -v:20 passed.flake8 --config=.flake8on all 3 modified files: passed with 0 errors.