Skip to content

Commit 8582e37

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent da6383e commit 8582e37

4 files changed

Lines changed: 19 additions & 37 deletions

File tree

conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,7 @@ def pytest_addoption(parser: Parser) -> None:
154154
)
155155

156156
# HuggingFace options
157-
hf_group.addoption(
158-
"--hf-access-token",
159-
default=os.environ.get("HF_ACCESS_TOKEN"),
160-
help="HF access token"
161-
)
157+
hf_group.addoption("--hf-access-token", default=os.environ.get("HF_ACCESS_TOKEN"), help="HF access token")
162158

163159

164160
def pytest_cmdline_main(config: Any) -> None:

tests/model_explainability/lm_eval/conftest.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,26 @@ def lmevaljob_hf(
4747
"enabled": True,
4848
},
4949
limit="0.01",
50-
pod = {
50+
pod={
5151
"container": {
5252
"resources": {
53-
"limits": {
54-
"cpu": "1",
55-
"memory": "8Gi",
56-
"nvidia.com/gpu": "1"
57-
},
58-
"requests": {
59-
"cpu": "1",
60-
"memory": "8Gi",
61-
"nvidia.com/gpu": "1"
62-
}
53+
"limits": {"cpu": "1", "memory": "8Gi", "nvidia.com/gpu": "1"},
54+
"requests": {"cpu": "1", "memory": "8Gi", "nvidia.com/gpu": "1"},
6355
},
6456
"env": [
65-
{ "name": "HF_TOKEN",
57+
{
58+
"name": "HF_TOKEN",
6659
"valueFrom": {
6760
"secretKeyRef": {
6861
"name": "hf-secret",
6962
"key": "HF_ACCESS_TOKEN",
7063
},
7164
},
7265
},
73-
{
74-
"name": "HF_ALLOW_CODE_EVAL",
75-
"value": "1"
76-
},
66+
{"name": "HF_ALLOW_CODE_EVAL", "value": "1"},
7767
],
7868
},
7969
},
80-
8170
) as job:
8271
yield job
8372

@@ -442,13 +431,14 @@ def lmevaljob_vllm_emulator_pod(
442431
def lmevaljob_s3_offline_pod(admin_client: DynamicClient, lmevaljob_s3_offline: LMEvalJob) -> Generator[Pod, Any, Any]:
443432
yield get_lmevaljob_pod(client=admin_client, lmevaljob=lmevaljob_s3_offline)
444433

434+
445435
@pytest.fixture(scope="function")
446436
def lmeval_hf_access_token(
447437
admin_client: DynamicClient,
448438
model_namespace: Namespace,
449439
pytestconfig: Config,
450440
) -> Secret:
451-
hf_access_token=pytestconfig.option.hf_access_token
441+
hf_access_token = pytestconfig.option.hf_access_token
452442
if not hf_access_token:
453443
raise MissingParameter(
454444
"HF access token is not set. "
@@ -461,7 +451,6 @@ def lmeval_hf_access_token(
461451
string_data={
462452
"HF_ACCESS_TOKEN": hf_access_token,
463453
},
464-
465454
wait_for_resource=True,
466455
) as secret:
467456
yield secret

tests/model_explainability/lm_eval/test_lm_eval.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
LMEVAL_TASKS: List[str] = get_lmeval_tasks(min_downloads=10000)
1212

13+
1314
@pytest.mark.parametrize(
1415
"model_namespace, lmevaljob_hf",
1516
[
@@ -48,10 +49,9 @@
4849
},
4950
id="custom_task",
5051
),
51-
], indirect=True,
52+
],
53+
indirect=True,
5254
)
53-
54-
5555
def test_lmeval_huggingface_model(admin_client, model_namespace, lmevaljob_hf_pod):
5656
"""Tests that verify running common evaluations (and a custom one) on a model pulled directly from HuggingFace.
5757
On each test we run a different evaluation task, limiting it to 0.5% of the questions on each eval."""

tests/model_explainability/lm_eval/utils.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def get_lmevaljob_pod(client: DynamicClient, lmevaljob: LMEvalJob, timeout: int
3535

3636
return lmeval_pod
3737

38+
3839
def get_lmeval_tasks(min_downloads: int = 10000) -> List[str]:
3940
"""
4041
Gets the list of supported LM-Eval tasks that have above a certain number of minimum downloads on HuggingFace.
@@ -51,22 +52,18 @@ def get_lmeval_tasks(min_downloads: int = 10000) -> List[str]:
5152
lmeval_tasks = pd.read_csv("tests/model_explainability/lm_eval/data/new_task_list.csv")
5253

5354
# filter for tasks that either exceed (min_downloads OR exist on the OpenLLM leaderboard)
54-
# AND exist on LMEval AND do not
55+
# AND exist on LMEval AND do not
5556

5657
filtered_df = lmeval_tasks[
57-
lmeval_tasks['Exists'] & (lmeval_tasks['Dataset'] != "MMMU/MMMU") & (
58-
(lmeval_tasks['HF dataset downloads'] >= min_downloads) |
59-
(lmeval_tasks['OpenLLM leaderboard'])
60-
)
58+
lmeval_tasks["Exists"]
59+
& (lmeval_tasks["Dataset"] != "MMMU/MMMU")
60+
& ((lmeval_tasks["HF dataset downloads"] >= min_downloads) | (lmeval_tasks["OpenLLM leaderboard"]))
6161
]
6262

6363
# group tasks by dataset and extract the task with shortest name in the group
64-
unique_tasks = (
65-
filtered_df
66-
.loc[filtered_df.groupby('Dataset')['Name'].apply(lambda x: x.str.len().idxmin())]
67-
)
64+
unique_tasks = filtered_df.loc[filtered_df.groupby("Dataset")["Name"].apply(lambda x: x.str.len().idxmin())]
6865

69-
unique_tasks = unique_tasks['Name'].tolist()
66+
unique_tasks = unique_tasks["Name"].tolist()
7067

7168
LOGGER.info(f"Number of unique LMEval tasks with more than {min_downloads} downloads: {len(unique_tasks)}")
7269

0 commit comments

Comments
 (0)