Skip to content

Commit

Permalink
Rename download_to_cache to from_hf_hub_to_cache (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk committed Sep 12, 2023
1 parent 2585be2 commit 6173024
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions curated_transformers/generation/auto_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class AutoGenerator(AutoModel[GeneratorWrapper]):
"""

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls,
*,
name: str,
revision: str = "main",
):
generator_cls = _resolve_generator_class(name)
generator_cls.download_to_cache(name=name, revision=revision)
generator_cls.from_hf_hub_to_cache(name=name, revision=revision)

@classmethod
def from_hf_hub(
Expand Down
6 changes: 3 additions & 3 deletions curated_transformers/generation/default_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ def __init__(
)

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[Self],
*,
name: str,
revision: str = "main",
):
AutoTokenizer.download_to_cache(name=name, revision=revision)
AutoCausalLM.download_to_cache(name=name, revision=revision)
AutoTokenizer.from_hf_hub_to_cache(name=name, revision=revision)
AutoCausalLM.from_hf_hub_to_cache(name=name, revision=revision)

@classmethod
def from_hf_hub(
Expand Down
2 changes: 1 addition & 1 deletion curated_transformers/generation/hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FromHFHub(ABC):

@classmethod
@abstractmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[Self],
*,
name: str,
Expand Down
4 changes: 2 additions & 2 deletions curated_transformers/models/auto_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def from_hf_hub(
raise NotImplementedError

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls,
*,
name: str,
Expand All @@ -108,7 +108,7 @@ def download_to_cache(
Model revision.
"""
module_cls = cls._resolve_model_cls(name, revision)
module_cls.download_to_cache(name=name, revision=revision)
module_cls.from_hf_hub_to_cache(name=name, revision=revision)


class AutoEncoder(AutoModel[EncoderModule]):
Expand Down
2 changes: 1 addition & 1 deletion curated_transformers/models/hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def from_hf_config(
raise NotImplementedError

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[Self],
*,
name: str,
Expand Down
4 changes: 2 additions & 2 deletions curated_transformers/tests/models/test_hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def test_sharded_model_checkpoints(torch_device):
)


def test_download_to_cache():
BERTEncoder.download_to_cache(
def test_from_hf_hub_to_cache():
BERTEncoder.from_hf_hub_to_cache(
name="explosion-testing/bert-test-caching",
revision="96a29a07d0fa4c24fd2675521add643e3c2581fc",
)
Expand Down
8 changes: 4 additions & 4 deletions curated_transformers/tests/tokenizers/test_hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from curated_transformers.tokenizers.legacy import BERTTokenizer


def test_download_to_cache():
Tokenizer.download_to_cache(
def test_from_hf_hub_to_cache():
Tokenizer.from_hf_hub_to_cache(
name="EleutherAI/gpt-neox-20b",
revision="9369f145ca7b66ef62760f9351af951b2d53b77f",
)
Expand All @@ -26,8 +26,8 @@ def test_download_to_cache():
)


def test_download_to_cache_legacy():
BERTTokenizer.download_to_cache(
def test_from_hf_hub_to_cache_legacy():
BERTTokenizer.from_hf_hub_to_cache(
name="bert-base-uncased",
revision="1dbc166cf8765166998eff31ade2eb64c8a40076",
)
Expand Down
4 changes: 2 additions & 2 deletions curated_transformers/tokenizers/auto_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AutoTokenizer:
# requires that the return type is Self.

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls,
*,
name: str,
Expand All @@ -60,7 +60,7 @@ def download_to_cache(
Model revision.
"""
tokenizer_cls = _resolve_tokenizer_class(name, revision)
tokenizer_cls.download_to_cache(name=name, revision=revision)
tokenizer_cls.from_hf_hub_to_cache(name=name, revision=revision)

@classmethod
def from_hf_hub(cls, *, name: str, revision: str = "main") -> TokenizerBase:
Expand Down
4 changes: 2 additions & 2 deletions curated_transformers/tokenizers/hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FromHFHub(ABC):

@classmethod
@abstractmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[SelfFromHFHub],
*,
name: str,
Expand Down Expand Up @@ -94,7 +94,7 @@ def _load_from_vocab_files(
raise NotImplementedError

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[SelfLegacyFromHFHub],
*,
name: str,
Expand Down
2 changes: 1 addition & 1 deletion curated_transformers/tokenizers/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def from_dir(cls: Type[Self], path: Path) -> Self:
)

@classmethod
def download_to_cache(
def from_hf_hub_to_cache(
cls: Type[Self],
*,
name: str,
Expand Down

0 comments on commit 6173024

Please sign in to comment.