Skip to content

Commit

Permalink
fix custom cache dir (huggingface#2226)
Browse files Browse the repository at this point in the history
* fix to not ignore HUGGINGFACE_HUB_CACHE in cache

* delete printlns

* delete newlines

* maybe fix trailing whitespace
  • Loading branch information
ErikKaum authored and yuanwu2017 committed Sep 25, 2024
1 parent 619eede commit 271ebb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion router/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ async fn main() -> Result<(), RouterError> {
}
let api = if use_api {
if std::env::var("HF_HUB_OFFLINE") == Ok("1".to_string()) {
let cache = Cache::default();
let cache = std::env::var("HUGGINGFACE_HUB_CACHE")
.map_err(|_| ())
.map(|cache_dir| Cache::new(cache_dir.into()))
.unwrap_or_else(|_| Cache::default());

tracing::warn!("Offline mode active using cache defaults");
Type::Cache(cache)
} else {
Expand Down

0 comments on commit 271ebb7

Please sign in to comment.