mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-09 10:26:38 +08:00
fix manage for new transformers (#1304)
This commit is contained in:
parent
b7f742ef56
commit
56e60ad5a6
@ -2,7 +2,22 @@ import argparse
|
|||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from huggingface_hub import scan_cache_dir
|
from huggingface_hub import scan_cache_dir
|
||||||
from transformers.commands.user import tabulate
|
|
||||||
|
|
||||||
|
def tabulate(rows: List[List[Union[str, int]]], headers: List[str]) -> str:
|
||||||
|
"""
|
||||||
|
Inspired by:
|
||||||
|
- stackoverflow.com/a/8356620/593036
|
||||||
|
- stackoverflow.com/questions/9535954/printing-lists-as-tabular-data
|
||||||
|
"""
|
||||||
|
col_widths = [max(len(str(x)) for x in col) for col in zip(*rows, headers)]
|
||||||
|
row_format = ("{{:{}}} " * len(headers)).format(*col_widths)
|
||||||
|
lines = []
|
||||||
|
lines.append(row_format.format(*headers))
|
||||||
|
lines.append(row_format.format(*["-" * w for w in col_widths]))
|
||||||
|
for row in rows:
|
||||||
|
lines.append(row_format.format(*row))
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
def ask_for_confirmation(message: str) -> bool:
|
def ask_for_confirmation(message: str) -> bool:
|
||||||
|
Loading…
Reference in New Issue
Block a user