From e0c8eecb7947754ce0c400715cecd2aa790c13f8 Mon Sep 17 00:00:00 2001 From: Tarry Singh Date: Thu, 28 Mar 2024 17:52:52 +0000 Subject: [PATCH] bazel: use OID as sha256 for Git LFS files to prevent unnecessary HuggingFace redownloads. --- bazel/huggingface.bzl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bazel/huggingface.bzl b/bazel/huggingface.bzl index 11eb0a7..dbe1545 100644 --- a/bazel/huggingface.bzl +++ b/bazel/huggingface.bzl @@ -82,8 +82,11 @@ def _huggingface_repository_impl(rctx): continue if (not includes or _glob(rctx, entry["path"], includes)): tpl = RAW_FILE_URL_REMPLATE - if ("lfs" in entry): + is_lfs = "lfs" in entry + sha256 = "" + if (is_lfs): tpl = LFS_FILE_URL_TEMPLATE + sha256 = entry["lfs"]["oid"] url = tpl.format( model = rctx.attr.model, commit = rctx.attr.commit, @@ -94,6 +97,7 @@ def _huggingface_repository_impl(rctx): output = entry["path"], canonical_id = entry["oid"], headers = headers, + sha256 = sha256, block = False, ))