resolve NameError in generate_reports caused by undefined config_file variable#400
Conversation
… config_file variable Signed-off-by: Aryan Patel <aryan.patel7291@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ARYANPATEL-BIT The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/assign @MooreZheng |
There was a problem hiding this comment.
Code Review
This pull request fixes NameError exceptions in generate_reports.py by correcting the variable names used in error messages for tracking and ReID benchmarking configuration files. Review feedback indicates that while the NameError is resolved, the script may still encounter a TypeError if the configuration file arguments are missing (None), as the current existence check does not handle null values. It is recommended to explicitly verify that these arguments are provided before checking the filesystem.
| tracking_config_file = args.tracking_benchmarking_config_file | ||
| if not utils.is_local_file(tracking_config_file): | ||
| raise SystemExit(f"not found benchmarking config({config_file}) file in local") | ||
| raise SystemExit(f"Tracking benchmarking config file not found: {tracking_config_file}") |
There was a problem hiding this comment.
While this change correctly resolves the NameError, the script will still crash with a TypeError on line 76 if the --tracking_benchmarking_config_file argument is not provided (i.e., it is None). This is because utils.is_local_file(None) calls os.path.isfile(None), which is invalid. This TypeError is then caught by the generic exception handler on line 96, resulting in a confusing error message for the user. Consider adding a check to ensure the argument is provided before verifying its existence on the local filesystem.
Description
This PR fixes a bug in the
generate_reports.pyscript for the MOT17 tracking benchmark where a missing configuration file would cause an opaqueNameErrorcrash rather than exiting cleanly with the intended error message.Motivation and Context
Currently, if a user has a misconfigured environment or missing paths, the error handling attempts to print a helpful error message and exit the script. However, the
f-stringreferenced an undefinedconfig_filevariable, causing Python to crash withNameError: name 'config_file' is not defined. This makes debugging difficult for users trying to setup the example.What has been changed
config_filevariable with the correct locally scoped variables:config_file→tracking_config_fileconfig_file→reid_config_fileFile changed:
examples/MOT17/multiedge_inference_bench/pedestrian_tracking/generate_reports.pyHow Has This Been Tested?
argsparametersif not utils.is_local_file(...)condition and triggers aSystemExitwith the safe stringNotes for Reviewers
This bug was completely blocking error-handling and debugging for the MOT17 multiedge-inference-bench example. The fix is localized to a single file with minimal risk of regressions.
Before:
After:
Fixes: #399