LocalDownloadFileMetadata
Metadata about a file in the local directory related to a download process
struct LocalDownloadFileMetadata
Metadata about a file in the local directory related to a download process
struct LocalDownloadFileMetadata
import Hub
struct HubApi
init(downloadBase: URL? = nil, hfToken: String? = nil, endpoint: String = "https://huggingface.co", useBackgroundSession: Bool = false)
static let shared: HubApi
func configuration(fileURL: URL) throws -> Config
Assumes the file is already present at local url. fileURL
is a complete local file path for the given model
func configuration(from filename: String, in repo: Repo) throws -> Config
Assumes the file has already been downloaded. filename
is relative to the download base.
func getFileMetadata(from repo: Repo, matching glob: String) async throws -> [FileMetadata]
func getFileMetadata(from repo: Repo, matching globs: [String] = []) async throws -> [FileMetadata]
func getFileMetadata(from repoId: String, matching glob: String) async throws -> [FileMetadata]
func getFileMetadata(from repoId: String, matching globs: [String] = []) async throws -> [FileMetadata]
func getFileMetadata(url: URL) async throws -> FileMetadata
func getFilenames(from repo: Repo, matching globs: [String] = []) async throws -> [String]
func getFilenames(from repo: Repo, matching glob: String) async throws -> [String]
func getFilenames(from repoId: String, matching globs: [String] = []) async throws -> [String]
func getFilenames(from repoId: String, matching glob: String) async throws -> [String]
func httpGet(for url: URL) async throws -> (Data, HTTPURLResponse)
Throws error if the response code is not 20X
func httpHead(for url: URL) async throws -> (Data, HTTPURLResponse)
Throws error if page does not exist or is not accessible. Allows relative redirects but ignores absolute ones for LFS files.
func localRepoLocation(_ repo: Repo) -> URL
@discardableResult func snapshot(from repo: Repo, matching glob: String, progressHandler: @escaping (Progress) -> Void = { _ in }) async throws -> URL
@discardableResult func snapshot(from repo: Repo, matching globs: [String] = [], progressHandler: @escaping (Progress) -> Void = { _ in }) async throws -> URL
@discardableResult func snapshot(from repoId: String, matching glob: String, progressHandler: @escaping (Progress) -> Void = { _ in }) async throws -> URL
@discardableResult func snapshot(from repoId: String, matching globs: [String] = [], progressHandler: @escaping (Progress) -> Void = { _ in }) async throws -> URL
func whoami() async throws -> Config
enum EnvironmentError
struct FileMetadata
Data structure containing information about a file versioned on the Hub
struct HubFileDownloader
struct Sibling
Model data for parsed filenames
struct SiblingsResponse
typealias Repo = Hub.Repo
typealias RepoType = Hub.RepoType
let commitHash: String
Commit hash of the file in the repo
let etag: String
ETag of the file in the repo. Used to check if the file has changed. For LFS files, this is the sha256 of the file. For regular files, it corresponds to the git hash.
let filename: String
Path of the file in the repo
let timestamp: Date
The timestamp of when the metadata was saved i.e. when the metadata was accurate