|
7 | 7 | from typing import TYPE_CHECKING, Any, Type, cast |
8 | 8 |
|
9 | 9 | import torch |
| 10 | + |
10 | 11 | from datasets.fingerprint import Hasher |
11 | 12 |
|
12 | 13 | from .. import DataDreamer |
@@ -489,9 +490,9 @@ def export_to_disk(self, path: str, adapter_only: bool = False) -> PreTrainedMod |
489 | 490 | from .train_hf_finetune import TrainHFFineTune |
490 | 491 | from .train_setfit_classifier import TrainSetFitClassifier |
491 | 492 |
|
492 | | - assert ( |
493 | | - not adapter_only or self.peft_config |
494 | | - ), "`adapter_only` can only be used if a `peft_config` was provided." |
| 493 | + assert not adapter_only or self.peft_config, ( |
| 494 | + "`adapter_only` can only be used if a `peft_config` was provided." |
| 495 | + ) |
495 | 496 |
|
496 | 497 | # Clear the directory |
497 | 498 | clear_dir(path) |
@@ -624,9 +625,9 @@ def publish_to_hf_hub( # noqa: C901 |
624 | 625 | from .train_hf_finetune import TrainHFFineTune |
625 | 626 | from .train_setfit_classifier import TrainSetFitClassifier |
626 | 627 |
|
627 | | - assert ( |
628 | | - not adapter_only or self.peft_config |
629 | | - ), "`adapter_only` can only be used if a `peft_config` was provided." |
| 628 | + assert not adapter_only or self.peft_config, ( |
| 629 | + "`adapter_only` can only be used if a `peft_config` was provided." |
| 630 | + ) |
630 | 631 |
|
631 | 632 | # Login |
632 | 633 | api = hf_hub_login(token=token) |
@@ -759,9 +760,9 @@ def publish_to_hf_hub( # noqa: C901 |
759 | 760 | f""" The training arguments can be found [here](training_args.json).""" |
760 | 761 | ) |
761 | 762 | if os.path.exists(self.model_name) and os.path.isdir(self.model_name): |
762 | | - readme_contents = readme_contents.replace("{base_model}", self.model_name) |
763 | | - else: |
764 | 763 | readme_contents = readme_contents.replace("\nbase_model: {base_model}", "") |
| 764 | + else: |
| 765 | + readme_contents = readme_contents.replace("{base_model}", self.model_name) |
765 | 766 | tags = tags + model_names |
766 | 767 | tags = ( |
767 | 768 | tags |
|
0 commit comments