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
Summary
m alora add-readmecrashes with a rawModuleNotFoundErrorwhenhuggingface_hubis not installed, rather than the friendly install hint used by every other CLI command.Steps to reproduce
Actual output:
Expected output (consistent with
m alora train,m serve, etc.):Root cause
cli/alora/commands.py:155importshuggingface_hubdirectly inside the function body without a guard:All other commands lazy-import their heavy dependencies with a
try/except ImportErrorblock 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_hubimport inalora_add_readmewith the same guard pattern used elsewhere: