Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LORAX_USE_GLOBAL_HF_TOKEN to be applied correctly even though request doesn't have api_token #542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/lorax_server/utils/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def get_model_source(
api_token: Optional[str] = None,
):
if source == HUB:
if not api_token and bool(os.environ.get("LORAX_USE_GLOBAL_HF_TOKEN", 0)):
# User initialized LoRAX to fallback to global HF token if request token is empty
api_token = os.environ.get("HUGGING_FACE_HUB_TOKEN")
return HubModelSource(model_id, revision, extension, api_token)
elif source == S3:
return S3ModelSource(model_id, revision, extension)
Expand Down
2 changes: 1 addition & 1 deletion server/lorax_server/utils/sources/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def download_file(self, filename: str, ignore_errors: bool = False) -> Optional[


def get_hub_api(token: Optional[str] = None) -> HfApi:
if token == "" and bool(os.environ.get("LORAX_USE_GLOBAL_HF_TOKEN", 0)):
if not token and bool(os.environ.get("LORAX_USE_GLOBAL_HF_TOKEN", 0)):
# User initialized LoRAX to fallback to global HF token if request token is empty
token = os.environ.get("HUGGING_FACE_HUB_TOKEN")
return HfApi(token=token)