Skip to content

Commit 1ecd27a

Browse files
solarpunkinAwni Hannun
andauthored
fix cli (ml-explore#827)
* fix cli * nit * fix typo in subpackages --------- Co-authored-by: Awni Hannun <awni@apple.com>
1 parent 1fe1b3c commit 1ecd27a

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

mlx_lm/cli.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,37 @@ def main():
1616
"lora",
1717
"manage",
1818
"perplexity",
19-
"quant.awq",
20-
"quant.dwq",
21-
"quant.dynamic_quant",
22-
"quant.gptq",
19+
"awq",
20+
"dwq",
21+
"dynamic_quant",
22+
"gptq",
2323
"server",
2424
"upload",
2525
)
26+
subpackages = {
27+
"awq": "quant",
28+
"dwq": "quant",
29+
"dynamic_quant": "quant",
30+
"gptq": "quant",
31+
}
2632
if len(sys.argv) < 2:
2733
raise ValueError(f"CLI requires a subcommand in {subcommands}")
2834
subcommand = sys.argv.pop(1)
2935
if subcommand in subcommands:
36+
if subpackage := subpackages.get(subcommand):
37+
subcommand = f"{subpackage}.{subcommand}"
3038
submodule = importlib.import_module(f"mlx_lm.{subcommand}")
3139
submodule.main()
3240
elif subcommand == "--version":
3341
from mlx_lm import __version__
3442

3543
print(__version__)
3644
elif subcommand in ("-h", "--help"):
37-
print(f"The supported subcommand are {subcommands}")
45+
print(f"The supported subcommands are {subcommands}")
3846
print()
3947
print(
4048
"For help on an individual subcommand, pass --help "
41-
"to the subommand. For example: mlx_lm.generate --help"
49+
"to the subcommand. For example: mlx_lm.generate --help"
4250
)
4351
else:
4452
raise ValueError(f"CLI requires a subcommand in {subcommands}")

0 commit comments

Comments
 (0)