mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-07-17 09:08:01 +00:00
Harden nvbench-compare CLI failure handling
Apply the same small stability fixes to the modern and legacy compare scripts: report malformed nested JSON through the structured parse-error path, reject directory comparisons that produce no matching JSON files, use the supported pipe table format for old tabulate versions, and retitle the summary plot as a GPU timing change. Add regression coverage for the modern comparator error paths and output formatting.
This commit is contained in:
@@ -3316,7 +3316,7 @@ def compare_benches(
|
||||
)
|
||||
)
|
||||
else:
|
||||
print(tabulate.tabulate(rows, headers=headers, tablefmt="markdown"))
|
||||
print(tabulate.tabulate(rows, headers=headers, tablefmt="pipe"))
|
||||
|
||||
print("")
|
||||
|
||||
@@ -3392,7 +3392,7 @@ def compare_benches(
|
||||
plt.close(fig)
|
||||
|
||||
if plot:
|
||||
title = "%SOL Bandwidth change"
|
||||
title = "GPU timing change"
|
||||
if len(comparison_device_names) == 1:
|
||||
title = f"{title} - {next(iter(comparison_device_names))}"
|
||||
if filter_plan.global_axis_filters:
|
||||
@@ -3574,6 +3574,12 @@ def main() -> int:
|
||||
to_compare.append((r, c))
|
||||
else:
|
||||
to_compare = [(files_or_dirs[0], files_or_dirs[1])]
|
||||
if not to_compare:
|
||||
print(
|
||||
f"No non-empty matching JSON files found in {files_or_dirs[0]!r} "
|
||||
f"and {files_or_dirs[1]!r}"
|
||||
)
|
||||
return 1
|
||||
|
||||
stats = ComparisonStats()
|
||||
|
||||
@@ -3590,7 +3596,7 @@ def main() -> int:
|
||||
except ValueError as exc:
|
||||
print(str(exc))
|
||||
return 1
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
except (AttributeError, KeyError, TypeError, IndexError) as exc:
|
||||
print(format_json_structure_error(ref, comp, exc))
|
||||
return 1
|
||||
|
||||
@@ -3659,7 +3665,7 @@ def main() -> int:
|
||||
except ValueError as exc:
|
||||
print(str(exc))
|
||||
return 1
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
except (AttributeError, KeyError, TypeError, IndexError) as exc:
|
||||
print(format_json_structure_error(ref, comp, exc))
|
||||
return 1
|
||||
|
||||
|
||||
@@ -1349,7 +1349,7 @@ def compare_benches(
|
||||
)
|
||||
)
|
||||
else:
|
||||
print(tabulate.tabulate(rows, headers=headers, tablefmt="markdown"))
|
||||
print(tabulate.tabulate(rows, headers=headers, tablefmt="pipe"))
|
||||
|
||||
print("")
|
||||
|
||||
@@ -1425,7 +1425,7 @@ def compare_benches(
|
||||
plt.close(fig)
|
||||
|
||||
if plot:
|
||||
title = "%SOL Bandwidth change"
|
||||
title = "GPU timing change"
|
||||
if len(comparison_device_names) == 1:
|
||||
title = f"{title} - {next(iter(comparison_device_names))}"
|
||||
if filter_plan.global_axis_filters:
|
||||
@@ -1557,6 +1557,12 @@ def main() -> int:
|
||||
to_compare.append((r, c))
|
||||
else:
|
||||
to_compare = [(files_or_dirs[0], files_or_dirs[1])]
|
||||
if not to_compare:
|
||||
print(
|
||||
f"No non-empty matching JSON files found in {files_or_dirs[0]!r} "
|
||||
f"and {files_or_dirs[1]!r}"
|
||||
)
|
||||
return 1
|
||||
|
||||
stats = ComparisonStats()
|
||||
|
||||
@@ -1573,7 +1579,7 @@ def main() -> int:
|
||||
except ValueError as exc:
|
||||
print(str(exc))
|
||||
return 1
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
except (AttributeError, KeyError, TypeError, IndexError) as exc:
|
||||
print(format_json_structure_error(ref, comp, exc))
|
||||
return 1
|
||||
|
||||
@@ -1635,7 +1641,7 @@ def main() -> int:
|
||||
except ValueError as exc:
|
||||
print(str(exc))
|
||||
return 1
|
||||
except (KeyError, TypeError, IndexError) as exc:
|
||||
except (AttributeError, KeyError, TypeError, IndexError) as exc:
|
||||
print(format_json_structure_error(ref, comp, exc))
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user