Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated test cases for accepting repo-key by default
  • Loading branch information
naveenku-jfrog committed Mar 3, 2026
commit db7b42b098d1936570717a0d51681e8b3f27be6b
49 changes: 28 additions & 21 deletions huggingface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ func initHuggingFaceTest(t *testing.T) {
serverDetails.Password = *tests.JfrogPassword
}

// NOTE: We do NOT auto-set HF_ENDPOINT here.
// If HF_ENDPOINT is not set, downloads go directly to HuggingFace Hub (huggingface.co)
// If HF_ENDPOINT is set (by user/CI), downloads go through Artifactory
// Build info tests will skip if HF_ENDPOINT is not set since they require Artifactory
}

func cleanHuggingFaceTest(t *testing.T) {
clientTestUtils.UnSetEnvAndAssert(t, coreutils.HomeDir)
clientTestUtils.UnSetEnvAndAssert(t, "HF_ENDPOINT")
clientTestUtils.UnSetEnvAndAssert(t, "HF_TOKEN")
tests.CleanFileSystem()
}

Expand Down Expand Up @@ -136,6 +134,7 @@ func TestHuggingFaceDownload(t *testing.T) {
args := []string{
"hf", "d", "sshleifer/tiny-gpt2",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

// Execute and verify success
Expand All @@ -162,6 +161,7 @@ func TestHuggingFaceDownloadWithRevision(t *testing.T) {
"hf", "d", "sshleifer/tiny-gpt2",
"--repo-type=model",
"--revision=main",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand All @@ -186,6 +186,7 @@ func TestHuggingFaceDownloadDataset(t *testing.T) {
args := []string{
"hf", "d", "hf-internal-testing/fixtures_image_utils",
"--repo-type=dataset",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -219,6 +220,7 @@ func TestHuggingFaceDownloadWithEtagTimeout(t *testing.T) {
"hf", "d", "sshleifer/tiny-gpt2",
"--repo-type=model",
"--etag-timeout=3600",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -259,6 +261,7 @@ func TestHuggingFaceUpload(t *testing.T) {
args := []string{
"hf", "u", tempDir, "test-org/test-model",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -296,6 +299,7 @@ func TestHuggingFaceUploadWithRevision(t *testing.T) {
"hf", "u", tempDir, "test-org/test-model",
"--repo-type=model",
"--revision=test-branch",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -336,6 +340,7 @@ func TestHuggingFaceUploadDataset(t *testing.T) {
args := []string{
"hf", "u", tempDir, "test-org/test-dataset",
"--repo-type=dataset",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -414,6 +419,7 @@ func TestHuggingFaceDownloadInvalidRepoID(t *testing.T) {
args := []string{
"hf", "d", "non-existent-org/non-existent-model-12345xyz",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -460,6 +466,7 @@ func TestHuggingFaceUploadEmptyDirectory(t *testing.T) {
args := []string{
"hf", "u", tempDir, "test-org/test-empty-model",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -491,6 +498,7 @@ func TestHuggingFaceUploadNonExistentDirectory(t *testing.T) {
args := []string{
"hf", "u", "/non/existent/path/to/model", "test-org/test-model",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -544,6 +552,7 @@ func TestHuggingFaceUploadWithSpecialCharactersInPath(t *testing.T) {
args := []string{
"hf", "u", specialDir, "test-org/test-special-chars-model",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -581,6 +590,7 @@ func TestHuggingFaceUploadOverwrite(t *testing.T) {
args := []string{
"hf", "u", tempDir, repoID,
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -617,15 +627,9 @@ func TestHuggingFaceDownloadWithBuildInfo(t *testing.T) {
// Check if python3 and huggingface_hub are available
checkHuggingFaceHubAvailable(t)

// Build info collection requires HF_ENDPOINT to be set (Artifactory HuggingFace remote)
// Skip if not configured - this test requires Artifactory setup
if os.Getenv("HF_ENDPOINT") == "" {
t.Skip("Skipping build info test: HF_ENDPOINT not set. Set HF_ENDPOINT to your Artifactory HuggingFace remote URL to run this test.")
}

jfrogCli := coreTests.NewJfrogCli(execMain, "jfrog", "")

buildName := "hf-download-build-test"
buildName := tests.HuggingFaceBuildName + "-download"
buildNumber := "1"

// Test download with build info flags
Expand All @@ -635,6 +639,7 @@ func TestHuggingFaceDownloadWithBuildInfo(t *testing.T) {
"--repo-type=model",
"--build-name=" + buildName,
"--build-number=" + buildNumber,
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -682,7 +687,7 @@ func TestHuggingFaceUploadWithBuildInfo(t *testing.T) {

jfrogCli := coreTests.NewJfrogCli(execMain, "jfrog", "")

buildName := "hf-upload-build-test"
buildName := tests.HuggingFaceBuildName + "-upload"
buildNumber := "1"

// Test upload with build info flags
Expand All @@ -691,6 +696,7 @@ func TestHuggingFaceUploadWithBuildInfo(t *testing.T) {
"--repo-type=model",
"--build-name=" + buildName,
"--build-number=" + buildNumber,
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand All @@ -715,15 +721,9 @@ func TestHuggingFaceDownloadWithBuildInfoAndModule(t *testing.T) {
// Check if python3 and huggingface_hub are available
checkHuggingFaceHubAvailable(t)

// Build info collection requires HF_ENDPOINT to be set (Artifactory HuggingFace remote)
// Skip if not configured - this test requires Artifactory setup
if os.Getenv("HF_ENDPOINT") == "" {
t.Skip("Skipping build info test: HF_ENDPOINT not set. Set HF_ENDPOINT to your Artifactory HuggingFace remote URL to run this test.")
}

jfrogCli := coreTests.NewJfrogCli(execMain, "jfrog", "")

buildName := "hf-download-module-build-test"
buildName := tests.HuggingFaceBuildName + "-download-module"
buildNumber := "1"
moduleName := "tiny-bert-model-module"

Expand All @@ -735,6 +735,7 @@ func TestHuggingFaceDownloadWithBuildInfoAndModule(t *testing.T) {
"--build-name=" + buildName,
"--build-number=" + buildNumber,
"--module=" + moduleName,
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -777,7 +778,7 @@ func TestHuggingFaceUploadWithBuildInfoAndProject(t *testing.T) {

jfrogCli := coreTests.NewJfrogCli(execMain, "jfrog", "")

buildName := "hf-upload-project-build-test"
buildName := tests.HuggingFaceBuildName + "-upload-project"
buildNumber := "1"
projectKey := "test-project"

Expand All @@ -788,6 +789,7 @@ func TestHuggingFaceUploadWithBuildInfoAndProject(t *testing.T) {
"--build-name=" + buildName,
"--build-number=" + buildNumber,
"--project=" + projectKey,
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err = jfrogCli.Exec(args...)
Expand Down Expand Up @@ -822,6 +824,7 @@ func TestHuggingFaceDownloadAndVerifyCache(t *testing.T) {
args := []string{
"hf", "d", "sshleifer/tiny-gpt2",
"--repo-type=model",
"--repo-key=" + tests.HuggingFaceRemoteRepo,
}

err := jfrogCli.Exec(args...)
Expand Down Expand Up @@ -863,9 +866,13 @@ func TestHuggingFaceDownloadAndVerifyCache(t *testing.T) {
// InitHuggingFaceTests initializes HuggingFace tests
func InitHuggingFaceTests() {
initArtifactoryCli()
cleanUpOldBuilds()
cleanUpOldRepositories()
tests.AddTimestampToGlobalVars()
createRequiredRepos()
}

// CleanHuggingFaceTests cleans up after HuggingFace tests
func CleanHuggingFaceTests() {
// Cleanup is handled per-test
deleteCreatedRepos()
}
6 changes: 6 additions & 0 deletions testdata/huggingface_remote_repository_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"key": "${HUGGINGFACE_REMOTE_REPO}",
"rclass": "remote",
"packageType": "huggingfaceml",
"url": "https://huggingface.co"
}
2 changes: 2 additions & 0 deletions utils/tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
ConanRemoteRepositoryConfig = "conan_remote_repository_config.json"
ConanVirtualRepositoryConfig = "conan_virtual_repository_config.json"
HelmLocalRepositoryConfig = "helm_local_repository_config.json"
HuggingFaceRemoteRepositoryConfig = "huggingface_remote_repository_config.json"
ReplicationTempCreate = "replication_push_create.json"
Repo1RepositoryConfig = "repo1_repository_config.json"
Repo2RepositoryConfig = "repo2_repository_config.json"
Expand Down Expand Up @@ -213,6 +214,7 @@ var (
ConanRemoteRepo = "cli-conan-remote"
ConanVirtualRepo = "cli-conan-virtual"
HelmLocalRepo = "cli-helm-local"
HuggingFaceRemoteRepo = "cli-huggingface-remote"
DockerLocalRepo = "cli-docker-local"
DockerLocalPromoteRepo = "cli-docker-local-promote"
DockerRemoteRepo = "cli-docker-remote"
Expand Down
6 changes: 5 additions & 1 deletion utils/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ var reposConfigMap = map[*string]string{
&ConanRemoteRepo: ConanRemoteRepositoryConfig,
&ConanVirtualRepo: ConanVirtualRepositoryConfig,
&HelmLocalRepo: HelmLocalRepositoryConfig,
&HuggingFaceRemoteRepo: HuggingFaceRemoteRepositoryConfig,
&RtDebianRepo: DebianTestRepositoryConfig,
&RtLfsRepo: GitLfsTestRepositoryConfig,
&RtRepo1: Repo1RepositoryConfig,
Expand Down Expand Up @@ -355,7 +356,7 @@ func GetNonVirtualRepositories() map[*string]string {
TestPoetry: {&PoetryLocalRepo, &PoetryRemoteRepo},
TestConan: {&ConanLocalRepo, &ConanRemoteRepo},
TestHelm: {&HelmLocalRepo},
TestHuggingFace: {},
TestHuggingFace: {&HuggingFaceRemoteRepo},
TestPlugins: {&RtRepo1},
TestXray: {&NpmRemoteRepo, &NugetRemoteRepo, &YarnRemoteRepo, &GradleRemoteRepo, &MvnRemoteRepo, &GoRepo, &GoRemoteRepo, &PypiRemoteRepo},
TestAccess: {&RtRepo1},
Expand Down Expand Up @@ -485,6 +486,7 @@ func getSubstitutionMap() map[string]string {
"${CONAN_REMOTE_REPO}": ConanRemoteRepo,
"${CONAN_VIRTUAL_REPO}": ConanVirtualRepo,
"${HELM_REPO}": HelmLocalRepo,
"${HUGGINGFACE_REMOTE_REPO}": HuggingFaceRemoteRepo,
"${BUILD_NAME1}": RtBuildName1,
"${BUILD_NAME2}": RtBuildName2,
"${BUNDLE_NAME}": BundleName,
Expand Down Expand Up @@ -554,6 +556,7 @@ func AddTimestampToGlobalVars() {
ConanRemoteRepo += uniqueSuffix
ConanVirtualRepo += uniqueSuffix
HelmLocalRepo += uniqueSuffix
HuggingFaceRemoteRepo += uniqueSuffix
RtDebianRepo += uniqueSuffix
RtLfsRepo += uniqueSuffix
RtRepo1 += uniqueSuffix
Expand Down Expand Up @@ -581,6 +584,7 @@ func AddTimestampToGlobalVars() {
PoetryBuildName += uniqueSuffix
ConanBuildName += uniqueSuffix
HelmBuildName += uniqueSuffix
HuggingFaceBuildName += uniqueSuffix
RtBuildName1 += uniqueSuffix
RtBuildName2 += uniqueSuffix
RtBuildNameWithSpecialChars += uniqueSuffix
Expand Down
Loading