candding 0.1.0

Pure candle embeddings for Rust with no ONNX: dense, sparse, multi-vector and rerank models today, image models on the roadmap
Documentation
use hf_hub::HFError;
use tempfile::tempdir;

use super::ID;
use super::config;
use super::hub;
use super::server::Server;
use super::server::closed_url;
use crate::hub::download::fetch;
use crate::hub::download::repository;
use crate::registry::WeightsFormat;

fn runtime() -> tokio::runtime::Runtime {
  tokio::runtime::Builder::new_current_thread()
    .enable_all()
    .build()
    .unwrap()
}

#[test]
fn the_hub_client_refuses_to_write_a_cache() {
  let cache = tempdir().unwrap();
  let repo = repository(&config(cache.path(), &closed_url()), ID).unwrap();
  let download = repo.download_file().filename("config.json").send();
  match runtime().block_on(download) {
    Err(HFError::CacheNotEnabled) => {}
    other => panic!("{other:?}"),
  }
}

#[test]
fn a_fetch_runs_inside_a_caller_s_async_runtime() {
  let server = Server::start(hub);
  let cache = tempdir().unwrap();
  let config = config(cache.path(), &server.url);
  let fetched =
    runtime().block_on(async { fetch(&config, ID, "main", WeightsFormat::Safetensors) });
  assert!(fetched.unwrap().is_dir());
}