Skip to content

Commit 08511eb

Browse files
authored
Rename HUGGINGFACE_API_KEY to HF_TOKEN (#6)
1 parent 1c1e3b4 commit 08511eb

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

USER_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Below is a sample command you can use to start a benchmark. The command will con
166166

167167
```shell
168168
# Optional. This is required when you load the tokenizer from huggingface.co with a model-id
169-
export HUGGINGFACE_API_KEY="<your-key>"
169+
export HF_TOKEN="<your-key>"
170170
# HF transformers will log a warning about torch not installed, since benchmark doesn't really need torch
171171
# and cuda, we use this env to disable the warning
172172
export TRANSFORMERS_VERBOSITY=error
@@ -580,7 +580,7 @@ docker run \
580580
-tid \
581581
--shm-size 5g \
582582
--ulimit nofile=65535:65535 \
583-
--env HUGGINGFACE_API_KEY="your_huggingface_api_key" \
583+
--env HF_TOKEN="your_HF_TOKEN" \
584584
--network benchmark-network \
585585
-v /mnt/data/models:/models \
586586
-v $(pwd)/llava-config.json:/genai-bench/llava-config.json \
@@ -630,7 +630,7 @@ docker run \
630630
-tid \
631631
--shm-size 5g \
632632
--ulimit nofile=65535:65535 \
633-
--env HUGGINGFACE_API_KEY="your_huggingface_api_key" \
633+
--env HF_TOKEN="your_HF_TOKEN" \
634634
--network benchmark-network \
635635
-v /mnt/data/models:/models \
636636
-v $HOST_OUTPUT_DIR:$CONTAINER_OUTPUT_DIR \

examples/dataset_configs/local_csv.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"source": {
33
"type": "file",
44
"path": "/data/prompts.csv",
5-
"file_format": "csv",
6-
"csv_column_index": 1
5+
"file_format": "csv"
76
},
87
"prompt_column": "prompt"
98
}

genai_bench/cli/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ def validate_tokenizer(model_tokenizer):
139139
# Load the tokenizer directly from the local path
140140
tokenizer = AutoTokenizer.from_pretrained(model_tokenizer)
141141
else:
142-
hf_token = os.environ.get("HUGGINGFACE_API_KEY")
142+
hf_token = os.environ.get("HF_TOKEN")
143143
if hf_token is None:
144144
raise click.BadParameter(
145-
"The HUGGINGFACE_API_KEY environment variable is not set. "
145+
"The HF_TOKEN environment variable is not set. "
146146
"It is a required parameter to download tokenizer from "
147147
"HuggingFace."
148148
)

genai_bench/data/sources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ def load(self) -> Any:
101101

102102
# Verify dataset exists
103103
try:
104-
dataset_info(self.config.path, token=os.environ.get("HUGGINGFACE_API_KEY"))
104+
dataset_info(self.config.path, token=os.environ.get("HF_TOKEN"))
105105
except DatasetNotFoundError as e:
106106
raise ValueError(
107107
f"Dataset '{self.config.path}' not found on HuggingFace Hub. "
108-
f"If it's a gated repo, please set HUGGINGFACE_API_KEY environment "
108+
f"If it's a gated repo, please set HF_TOKEN environment "
109109
f"variable."
110110
) from e
111111

tests/cli/test_cli_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def default_options():
6060

6161
@pytest.fixture
6262
def mock_env_variables():
63-
with patch.dict("os.environ", {"HUGGINGFACE_API_KEY": "dummy_key"}):
63+
with patch.dict("os.environ", {"HF_TOKEN": "dummy_key"}):
6464
yield # Yield ensures the patch is active for the duration of the test
6565

6666

tests/cli/test_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_validate_tokenizer_with_hf_api(monkeypatch):
134134
hf_token = "mock_api_key"
135135
mock_tokenizer = MagicMock()
136136

137-
monkeypatch.setenv("HUGGINGFACE_API_KEY", hf_token)
137+
monkeypatch.setenv("HF_TOKEN", hf_token)
138138

139139
with patch(
140140
"transformers.AutoTokenizer.from_pretrained",
@@ -151,7 +151,7 @@ def test_validate_tokenizer_with_hf_api(monkeypatch):
151151

152152
def test_validate_tokenizer_no_hf_token(monkeypatch):
153153
monkeypatch.setattr(Path, "exists", lambda self: False)
154-
monkeypatch.delenv("HUGGINGFACE_API_KEY", raising=False)
154+
monkeypatch.delenv("HF_TOKEN", raising=False)
155155

156156
model_name = "bert-base-uncased"
157157

0 commit comments

Comments
 (0)