Skip to content

HubApi snapshot doesn't check existing files list in offline mode #294

@nezhyborets

Description

@nezhyborets

Hi guys.

It looks like in HubApi method

func snapshot(from repo: Repo, revision: String = "main", matching globs: [String] = [], progressHandler: @escaping (Progress) -> Void = { _ in })
        async throws -> URL { ... }

specifically in it's "offline mode" part - the code does check integrity of existing files, but doesn't check if the list of existing files is "complete".

This leads to the issue when if for some reason a file went missing from a model directory - offline load of the model would still finish successfully, even though I believe it should return error in such case, because a file could be some very important file, like *.safetensors.

I could make a PR to fix this. The method could, after successful online download, remember filenames returned by try await getFilenames(from: repo, revision: revision, matching: globs) by putting them to some ./.another_metadata file. Then during offline load, if actual files in folder don't have any of remembered filenames - such offline load would be considered failed, so that the user could fallback to online load or at least understand that there is an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions