Struct hf_hub::api::sync::ApiRepo

source ·
pub struct ApiRepo { /* private fields */ }
Expand description

Shorthand for accessing things within a particular repo

Implementations§

source§

impl ApiRepo

source

pub fn url(&self, filename: &str) -> String

Get the fully qualified URL of the remote filename

let api = Api::new().unwrap();
let url = api.model("gpt2".to_string()).url("model.safetensors");
assert_eq!(url, "https://huggingface.co/gpt2/resolve/main/model.safetensors");
source

pub fn get(&self, filename: &str) -> Result<PathBuf, ApiError>

This will attempt the fetch the file locally first, then [Api.download] if the file is not present.

use hf_hub::{api::sync::Api};
let api = Api::new().unwrap();
let local_filename = api.model("gpt2".to_string()).get("model.safetensors").unwrap();
source

pub fn download(&self, filename: &str) -> Result<PathBuf, ApiError>

Downloads a remote file (if not already present) into the cache directory to be used locally. This functions require internet access to verify if new versions of the file exist, even if a file is already on disk at location.

let api = Api::new().unwrap();
let local_filename = api.model("gpt2".to_string()).download("model.safetensors").unwrap();
source

pub fn info(&self) -> Result<RepoInfo, ApiError>

Get information about the Repo

use hf_hub::{api::sync::Api};
let api = Api::new().unwrap();
api.model("gpt2".to_string()).info();
source

pub fn info_request(&self) -> Request

Get the raw ureq::Request with the url and method already set

let api = Api::new().unwrap();
api.model("gpt2".to_owned())
    .info_request()
    .query("blobs", "true")
    .call();

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V