Skip to content

Fix #367: reportgen crashes with AttributeError on Namespace.file#368

Open
idevasena wants to merge 2 commits into
mlcommons:mainfrom
idevasena:fix/367-reportgen-attribute-error
Open

Fix #367: reportgen crashes with AttributeError on Namespace.file#368
idevasena wants to merge 2 commits into
mlcommons:mainfrom
idevasena:fix/367-reportgen-attribute-error

Conversation

@idevasena
Copy link
Copy Markdown
Contributor

@idevasena idevasena commented May 12, 2026

Fixes #367.

mlpstorage reports reportgen (and any other non-benchmark subcommand) crashed at startup with AttributeError: 'Namespace' object has no attribute 'file'. The CLI parser's data-access-protocol consolidation block read parsed_args.file and parsed_args.object unconditionally, but those attributes only exist on subcommands that call add_storage_type_arguments() — namely training, checkpointing, vectordb, and kvcache. The reports, history, and lockfile subcommands never define those flags, so their Namespace doesn't carry them.

This change guards the consolidation on attribute presence. Behavior on benchmark subcommands is preserved bit-for-bit; non-benchmark subcommands now parse cleanly and simply don't get a data_access_protocol attribute (downstream code already reads it via getattr(self.args, 'data_access_protocol', None) in mlpstorage_py/benchmarks/dlio.py:136, so nothing else has to change).

Regression context

The bug entered with commit 39e657d (PR #359, "Bug fixes and performance enhancements: object storage, checkpointing, Parquet loading"), which introduced the --file / --object storage-type flags and the consolidation block but didn't account for subparsers that don't opt into those flags.

Root cause

In mlpstorage_py/cli_parser.py, inside parse_arguments() after parser.parse_args():

Consolidate the data access protocol into a single field

if parsed_args.file:
    parsed_args.data_access_protocol = "file"
else:
    parsed_args.data_access_protocol = parsed_args.object
del parsed_args.file
del parsed_args.object

A grep across the package confirms add_storage_type_arguments() (in mlpstorage_py/cli/common_args.py) is only invoked from training_args.py, checkpointing_args.py, vectordb_args.py, and kvcache_args.py. The reports, history, and lockfile subparsers never call it, so their parsed Namespace has no file or object attribute and the block above raises before any subcommand logic runs. The docstring of add_storage_type_arguments() already states the intended contract — benchmarks that don't use object storage "simply ignore the flags; those that do can check args.file / args.object" — but the parser's consolidation step didn't honor it.

Fix

Gate the consolidation block on attribute presence, and use getattr for the reads so a benchmark subcommand that defines only one of the two flags still works:

Consolidate the data access protocol into a single field.

# The --file / --object flags are only defined on benchmark subcommands
# that call add_storage_type_arguments() (training, checkpointing,
# vectordb, kvcache). Other subcommands (reports, history, lockfile)
# do not define them, so guard the consolidation on attribute presence.
if hasattr(parsed_args, "file") or hasattr(parsed_args, "object"):
    if getattr(parsed_args, "file", False):
        parsed_args.data_access_protocol = "file"
    else:
        parsed_args.data_access_protocol = getattr(parsed_args, "object", None)
    # Clean up the raw flags so downstream code uses data_access_protocol.
    for _attr in ("file", "object"):
        if hasattr(parsed_args, _attr):
            delattr(parsed_args, _attr)
Files changed
  • mlpstorage_py/cli_parser.py — guarded consolidation block (7 lines removed, 14 added)
  • tests/unit/test_cli.py — added TestParseArgumentsStorageFlagConsolidation with 5 tests (3 regression tests for non-benchmark subcommands, 2 lock-in tests for benchmark subcommands)

idevasena added 2 commits May 12, 2026 04:00
…commands

   reports/history/lockfile subparsers do not call add_storage_type_arguments(),
   so their Namespace has no .file or .object attribute. The unconditional
   read and delete in parse_arguments() crashed with AttributeError. Gate the
   consolidation on attribute presence; downstream code already uses
   getattr(args, 'data_access_protocol', None).

   Fixes mlcommons#367

Signed-off-by: Devasena Inupakutika <devasena.i@samsung.com>
@idevasena idevasena requested a review from a team May 12, 2026 04:17
@github-actions
Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reportgen crashes with AttributeError: 'Namespace' object has no attribute 'file'

2 participants