fix: string indentation with textwrap.dedent (#510)

* fix: string indentation with textwrap.dedent

* update formatting
This commit is contained in:
Sugato Ray 2024-03-01 01:23:01 -05:00 committed by GitHub
parent f03c8a7b44
commit 3acc1ec84e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,7 @@ import logging
import shutil import shutil
import time import time
from pathlib import Path from pathlib import Path
from textwrap import dedent
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
import mlx.core as mx import mlx.core as mx
@ -437,7 +438,8 @@ def upload_to_hub(path: str, upload_repo: str, hf_path: str):
card = ModelCard.load(hf_path) card = ModelCard.load(hf_path)
card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"] card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
card.text = f""" card.text = dedent(
f"""
# {upload_repo} # {upload_repo}
This model was converted to MLX format from [`{hf_path}`](). This model was converted to MLX format from [`{hf_path}`]().
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model. Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
@ -454,6 +456,7 @@ model, tokenizer = load("{upload_repo}")
response = generate(model, tokenizer, prompt="hello", verbose=True) response = generate(model, tokenizer, prompt="hello", verbose=True)
``` ```
""" """
)
card.save(os.path.join(path, "README.md")) card.save(os.path.join(path, "README.md"))
logging.set_verbosity_info() logging.set_verbosity_info()