-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Downloading private adapters from HF (#443)
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
|
||
import pytest | ||
from huggingface_hub.utils import RepositoryNotFoundError | ||
|
||
from lorax_server.adapters.utils import download_adapter | ||
from lorax_server.utils.sources import HUB | ||
|
||
|
||
def test_download_private_adapter_hf(): | ||
# store and unset HUGGING_FACE_HUB_TOKEN from the environment | ||
token = os.environ.pop("HUGGING_FACE_HUB_TOKEN", None) | ||
assert token is not None, "HUGGING_FACE_HUB_TOKEN must be set in the environment to run this test" | ||
|
||
# verify download fails without the token set | ||
with pytest.raises(RepositoryNotFoundError): | ||
download_adapter("predibase/test-private-lora", HUB, api_token=None) | ||
|
||
# pass in the token and verify download succeeds | ||
download_adapter("predibase/test-private-lora", HUB, api_token=token) | ||
|
||
# set the token back in the environment | ||
os.environ["HUGGING_FACE_HUB_TOKEN"] = token |