Skip to content

Commit a88a526

Browse files
authored
Fix path in cache (#915)
* fix * need to expand path for home
1 parent 02bf135 commit a88a526

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

docs/source/caching.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ For custom models you need to add a cache to the model class and decorators on a
5050
To clear cache for a specific model, delete the corresponding directory:
5151

5252
```bash
53-
rm -rf ./cache/huggingface/lighteval/predictions/{model_name}/{model_hash}/
53+
rm -rf ~/.cache/huggingface/lighteval/predictions/{model_name}/{model_hash}/
5454
```
5555

5656
To clear all caches:
5757

5858
```bash
59-
rm -rf ./cache/huggingface/lighteval/predictions
59+
rm -rf ~/.cache/huggingface/lighteval/predictions
6060
```

src/lighteval/models/abstract_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ModelConfig(BaseModel, extra="forbid"):
8181

8282
generation_parameters: GenerationParameters = GenerationParameters()
8383
system_prompt: str | None = None
84-
cache_dir: str = "./cache/huggingface/lighteval"
84+
cache_dir: str = "~/.cache/huggingface/lighteval"
8585

8686
@classmethod
8787
def from_path(cls, path: str):

src/lighteval/utils/cache_management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import hashlib
2525
import json
2626
import logging
27+
import os
2728
from dataclasses import asdict
2829
from enum import Enum
2930
from pathlib import Path
@@ -68,7 +69,7 @@ def __init__(self, model_config: ModelConfig):
6869
model_config: Configuration for the model being cached
6970
cache_dir: Directory to store cache files
7071
"""
71-
self.cache_dir = Path(model_config.cache_dir)
72+
self.cache_dir = Path(os.path.expanduser(model_config.cache_dir))
7273
self.model_config = model_config
7374
self.model_hash = self.get_model_hash(model_config)
7475

tests/models/endpoints/test_endpoint_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class TestInferenceEndpointModelConfig:
7171
"truncate_prompt": None,
7272
"response_format": None,
7373
},
74-
"cache_dir": "./cache/huggingface/lighteval",
74+
"cache_dir": "~/.cache/huggingface/lighteval",
7575
},
7676
),
7777
],

tests/models/endpoints/test_tgi_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TestTGIModelConfig:
5858
"truncate_prompt": None,
5959
"response_format": None,
6060
},
61-
"cache_dir": "./cache/huggingface/lighteval",
61+
"cache_dir": "~/.cache/huggingface/lighteval",
6262
},
6363
),
6464
],

0 commit comments

Comments
 (0)