Skip to content

fix: missing friendly ImportError for m alora add-readme without [hf] #855

Closed

Description

@planetf1

Summary

m alora add-readme crashes with a raw ModuleNotFoundError when huggingface_hub is not installed, rather than the friendly install hint used by every other CLI command.

Steps to reproduce

pip install "mellea[cli]"  # without [hf]
m alora add-readme data.jsonl --basemodel gpt2 --name myorg/mymodel

Actual output:

ModuleNotFoundError: No module named 'huggingface_hub'

Expected output (consistent with m alora train, m serve, etc.):

ImportError: The 'm alora' command requires extra dependencies.
Please install them with: pip install "mellea[hf]"

Root cause

cli/alora/commands.py:155 imports huggingface_hub directly inside the function body without a guard:

def alora_add_readme(...):
    from huggingface_hub import HfFolder, create_repo, upload_file  # no try/except

All other commands lazy-import their heavy dependencies with a try/except ImportError block pointing to the correct extra. This one was missed.

Found during

Code review and isolated-environment testing of PR #789, which introduced the friendly import error pattern across the rest of the CLI.

Fix

Wrap the huggingface_hub import in alora_add_readme with the same guard pattern used elsewhere:

try:
    from huggingface_hub import HfFolder, create_repo, upload_file
except ImportError as e:
    raise ImportError(
        "The 'm alora' command requires extra dependencies. "
        'Please install them with: pip install "mellea[hf]"'
    ) from e

Activity

  1. added
    enhancement
    on Apr 14, 2026
  2. added
    bug
    and removed
    enhancement
    on May 19, 2026
  3. self-assigned this
    on May 19, 2026
  4. added
    area/alora
    area/backends
    area/cli
    on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/aloraarea/backendsarea/clibug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions