-
Notifications
You must be signed in to change notification settings - Fork 61
Record pass/fail status in the scenario HTML report #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,32 @@ | ||
| {% extends "base-report.jinja2" %} | ||
|
|
||
| {% block extra_head %} | ||
| <style> | ||
| .status-passed { color: var(--nv-green-strong); font-weight: 600; } | ||
| .status-failed { color: #c0392b; font-weight: 600; } | ||
| </style> | ||
| {% endblock %} | ||
|
|
||
| {% block content %} | ||
| <table> | ||
| <tr> | ||
| <th>Test</th> | ||
| <th>Description</th> | ||
| <th>Status</th> | ||
| <th>Results</th> | ||
| <th>Nodes</th> | ||
| </tr> | ||
| {% for item in report_items %} | ||
| <tr> | ||
| <td>{{ item.name }}</td> | ||
| <td>{{ item.description }}</td> | ||
| {% if item.is_successful is none %} | ||
| <td>Unknown</td> | ||
| {% elif item.is_successful %} | ||
| <td class="status-passed">PASSED</td> | ||
| {% else %} | ||
| <td class="status-failed">FAILED{% if item.error_message %}<br>{{ item.error_message }}{% endif %}</td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 4 'jinja2\.Environment|autoescape' src/cloudai
rg -n -C 6 'def was_run_successful|JobStatusResult\(' src/cloudai
rg -n -C 4 'error_message|general-report|script' testsRepository: NVIDIA/cloudai Length of output: 50371 🤖 get_repo_knowledge executed:
Length of output: 21058 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate template ---'
cat -n src/cloudai/util/general-report.jinja2 | sed -n '20,34p'
printf '%s\n' '--- report-related definitions ---'
fd -t f -i 'report|status' src/cloudai | sort
rg -n -C 8 'jinja2\.Environment|class StatusReporter|error_message|def was_run_successful' src/cloudai/util src/cloudai --glob '*.py' --glob '*.jinja2' | head -n 300
printf '%s\n' '--- focused tests ---'
fd -t f -i 'report|status' tests | sort
rg -n -C 5 'general-report|StatusReporter|error_message|<script>|autoescape' tests --glob '*.py' --glob '*.jinja2' | head -n 300Repository: NVIDIA/cloudai Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- StatusReporter implementation ---'
cat -n src/cloudai/reporter.py | sed -n '88,116p'
printf '%s\n' '--- all production error_message assignments ---'
rg -n 'error_message\s*=' src/cloudai --glob '*.py' | head -n 250
printf '%s\n' '--- report rendering tests ---'
cat -n tests/test_reporter.py | sed -n '390,435p'Repository: NVIDIA/cloudai Length of output: 12287 🌐 Web query:
💡 Result: The jinja2.select_autoescape function is the recommended way to configure automatic escaping in Jinja2 based on the template filename [1][2]. It allows you to define which file extensions should trigger automatic escaping for your templates [1]. Key parameters and behavior: 1. enabled_extensions: An iterable of file extensions (e.g., ('html', 'htm', 'xml')) for which autoescaping should be enabled [1][2]. 2. disabled_extensions: An iterable of extensions for which autoescaping should be explicitly disabled [1]. 3. default_for_string: A boolean determining whether autoescaping is enabled for templates created from strings (default is True) [1]. 4. default: A boolean that sets the default autoescaping state if a template's extension does not match any in enabled_extensions or disabled_extensions (default is False) [1]. Example Usage: You can pass the result of select_autoescape to the autoescape parameter when initializing the Jinja2 Environment: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( enabled_extensions=('html', 'xml'), default_for_string=True, default=False)) When a template is loaded, Jinja2 uses the template's filename to determine if it matches an extension in your configuration [1][2]. If you use multiple extensions or extra suffixes (e.g.,.html.jinja), you must ensure these are explicitly included in your enabled_extensions list, as the function checks the file extension [3][4]. If a template is loaded from a string rather than a file, the filename provided to the autoescape function is None, and the default_for_string setting is used [1][2]. Citations:
XSS Reachability: Internal Enable HTML autoescaping for the
Suggested fix- jinja2.Environment(loader=jinja2.FileSystemLoader(self.template_file_path))
+ jinja2.Environment(
+ loader=jinja2.FileSystemLoader(self.template_file_path),
+ autoescape=jinja2.select_autoescape(enabled_extensions=("html", "xml", "jinja2")),
+ )🤖 Prompt for AI Agents |
||
| {% endif %} | ||
| {% if item.logs_path %} | ||
| <td><a href="{{ item.logs_path }}">logs</a></td> | ||
| {% else %} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
Reuse one status snapshot for both outputs.
from_test_runs()now callswas_run_successful()for every test, andStatusReporter.print_summary()calls it again. The NCCL implementation reads the completestdout.txton each call. Cache the status result and use the same snapshot for the HTML report and terminal summary. This also prevents the two outputs from disagreeing if the output changes between calls.🤖 Prompt for AI Agents