mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-07-01 11:47:33 +00:00
Ensure that bulk-debug-python script is enclosed in markers
This permits extracting Python script using Unix CLI tools when `--bulk-debug-python stdout` is used. Added example of using this to nvbench_compare.md doc.
This commit is contained in:
@@ -996,6 +996,7 @@ def make_bulk_debug_row(
|
||||
|
||||
def format_bulk_debug_python(bulk_rows: list[dict[str, Any]]) -> str:
|
||||
return (
|
||||
"# NVB-BULK-BEGIN\n"
|
||||
"# Generated by nvbench-compare --bulk-debug-python.\n"
|
||||
"import numpy as np\n\n"
|
||||
f"bulk_rows = {pprint.pformat(bulk_rows, sort_dicts=False)}\n\n"
|
||||
@@ -1028,6 +1029,7 @@ def format_bulk_debug_python(bulk_rows: list[dict[str, Any]]) -> str:
|
||||
"# row = bulk_rows[0]\n"
|
||||
"# arrays = load_bulk_data(row)\n"
|
||||
"# ambiguous = [row for row in bulk_rows if row['status'] == 'AMBG']\n"
|
||||
"# NVB-BULK-END\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -495,6 +495,8 @@ def test_format_bulk_debug_python_loads_arrays(tmp_path, nvbench_compare):
|
||||
)
|
||||
namespace = {}
|
||||
|
||||
assert script.startswith("# NVB-BULK-BEGIN\n")
|
||||
assert script.endswith("# NVB-BULK-END\n")
|
||||
exec(script, namespace)
|
||||
|
||||
arrays = namespace["load_bulk_data"](namespace["bulk_rows"][0])
|
||||
@@ -1847,9 +1849,11 @@ def test_main_prints_bulk_debug_python_to_stdout(monkeypatch, capsys, nvbench_co
|
||||
|
||||
assert nvbench_compare.main() == 0
|
||||
output = capsys.readouterr().out
|
||||
assert "# NVB-BULK-BEGIN" in output
|
||||
assert "bulk_rows = [" in output
|
||||
assert "'status': 'AMBG'" in output
|
||||
assert "def load_bulk_data(row):" in output
|
||||
assert "# NVB-BULK-END" in output
|
||||
|
||||
|
||||
def test_compare_benches_defaults_to_interval_display(monkeypatch, nvbench_compare):
|
||||
|
||||
Reference in New Issue
Block a user