Skip to content

Commit 7219cb1

Browse files
Updated e2e test cases for hugging-face (#3372)
* Updated e2e test cases for hugging-face
1 parent a9c1d63 commit 7219cb1

File tree

9 files changed

+647
-94
lines changed

9 files changed

+647
-94
lines changed

.github/workflows/huggingfaceTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
with:
6363
python-version: '3.11'
6464

65-
- name: Install HuggingFace CLI
65+
- name: Install HuggingFace Library
6666
if: matrix.os.name != 'macos'
6767
run: |
6868
pip install huggingface_hub

buildtools/cli.go

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,15 +1160,32 @@ func huggingFaceUploadCmd(c *cli.Context, hfArgs []string) error {
11601160
if repoID == "" {
11611161
return cliutils.PrintHelpAndReturnError("Repository ID cannot be empty.", c)
11621162
}
1163-
revision := ""
1164-
if c.String("revision") != "" {
1165-
revision = c.String("revision")
1163+
serverDetails, err := coreConfig.GetDefaultServerConf()
1164+
if err != nil {
1165+
return err
1166+
}
1167+
if serverDetails == nil {
1168+
return fmt.Errorf("no default server configuration found. Please configure a server using 'jfrog config add' or specify a server using --server-id")
1169+
}
1170+
buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c)
1171+
if err != nil {
1172+
return err
1173+
}
1174+
revision := c.String("revision")
1175+
if revision == "" {
1176+
revision = "main"
11661177
}
11671178
repoType := c.String("repo-type")
11681179
if repoType == "" {
11691180
repoType = "model"
11701181
}
1171-
huggingFaceUploadCmd := huggingfaceCommands.NewHuggingFaceUpload().SetFolderPath(folderPath).SetRepoId(repoID).SetRepoType(repoType).SetRevision(revision)
1182+
huggingFaceUploadCmd := huggingfaceCommands.NewHuggingFaceUpload().
1183+
SetFolderPath(folderPath).
1184+
SetRepoId(repoID).
1185+
SetRepoType(repoType).
1186+
SetRevision(revision).
1187+
SetServerDetails(serverDetails).
1188+
SetBuildConfiguration(buildConfiguration)
11721189
return commands.Exec(huggingFaceUploadCmd)
11731190
}
11741191

@@ -1177,18 +1194,24 @@ func huggingFaceDownloadCmd(c *cli.Context, hfArgs []string) error {
11771194
if len(hfArgs) < 1 {
11781195
return cliutils.PrintHelpAndReturnError("Model/Dataset name is required.", c)
11791196
}
1180-
const eTagTimeout = 86400
1197+
const defaultETagTimeout = 86400
11811198
repoID := hfArgs[0]
11821199
if repoID == "" {
11831200
return cliutils.PrintHelpAndReturnError("Model/Dataset name cannot be empty.", c)
11841201
}
1185-
revision := ""
1186-
if c.String("revision") != "" {
1187-
revision = c.String("revision")
1202+
serverDetails, err := coreConfig.GetDefaultServerConf()
1203+
if err != nil {
1204+
return err
1205+
}
1206+
if serverDetails == nil {
1207+
return fmt.Errorf("no default server configuration found. Please configure a server using 'jfrog config add' or specify a server using --server-id")
11881208
}
1189-
etagTimeout := eTagTimeout
1209+
buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c)
1210+
if err != nil {
1211+
return err
1212+
}
1213+
etagTimeout := defaultETagTimeout
11901214
if c.String("etag-timeout") != "" {
1191-
var err error
11921215
etagTimeout, err = strconv.Atoi(c.String("etag-timeout"))
11931216
if err != nil {
11941217
return errorutils.CheckErrorf("invalid etag-timeout value: %s", c.String("etag-timeout"))
@@ -1198,7 +1221,17 @@ func huggingFaceDownloadCmd(c *cli.Context, hfArgs []string) error {
11981221
if repoType == "" {
11991222
repoType = "model"
12001223
}
1201-
huggingFaceDownloadCmd := huggingfaceCommands.NewHuggingFaceDownload().SetRepoId(repoID).SetRepoType(repoType).SetRevision(revision).SetEtagTimeout(etagTimeout)
1224+
revision := c.String("revision")
1225+
if revision == "" {
1226+
revision = "main"
1227+
}
1228+
huggingFaceDownloadCmd := huggingfaceCommands.NewHuggingFaceDownload().
1229+
SetRepoId(repoID).
1230+
SetRepoType(repoType).
1231+
SetRevision(revision).
1232+
SetEtagTimeout(etagTimeout).
1233+
SetServerDetails(serverDetails).
1234+
SetBuildConfiguration(buildConfiguration)
12021235
return commands.Exec(huggingFaceDownloadCmd)
12031236
}
12041237

docs/buildtools/huggingface/help.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package huggingface
22

3-
var Usage = []string{"hf d <model-name>",
4-
"hf u <folder-path> <repo-id>"}
3+
var Usage = []string{"hf download <model-name>",
4+
"hf upload <folder-path> <repo-id>"}
55

66
func GetDescription() string {
77
return `Download or upload models/datasets from/to HuggingFace Hub.`
88
}
99

1010
func GetArguments() string {
11-
return ` d <model-name>
11+
return ` download <model-name>
1212
Download a model/dataset from HuggingFace Hub.
1313
model-name
1414
The HuggingFace model repository ID (e.g., 'bert-base-uncased' or 'username/model-name').
1515
16-
u <folder-path> <repo-id>
16+
upload <folder-path> <repo-id>
1717
Upload a model or dataset folder to HuggingFace Hub.
1818
folder-path
1919
Path to the folder to upload.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/jfrog/build-info-go v1.13.1-0.20260216093441-40a4dc563294
2020
github.com/jfrog/gofrog v1.7.6
2121
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260216085810-1ade6c26b3df
22-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260220110856-b6523f01f9c7
22+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260227101327-7478579b5f25
2323
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260218080258-3bf55ed18973
2424
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260202100913-d9ee9476845a
2525
github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20260213131956-d1d39bf3a042
@@ -258,7 +258,7 @@ replace github.com/ktrysmt/go-bitbucket => github.com/ktrysmt/go-bitbucket v0.9.
258258

259259
//replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core
260260

261-
// replace github.com/jfrog/jfrog-cli-artifactory => github.com/fluxxBot/jfrog-cli-artifactory v0.0.0-20260130044429-464a5025d08a
261+
//replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260226133041-8d510cc4e5f6
262262

263263
//replace github.com/jfrog/build-info-go => github.com/fluxxBot/build-info-go v1.10.10-0.20260105070825-d3f36f619ba5
264264

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
417417
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
418418
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260216085810-1ade6c26b3df h1:raSyae8/h1y8HtzFLf7vZZj91fP/qD94AX+biwBJiqs=
419419
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260216085810-1ade6c26b3df/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw=
420-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260220110856-b6523f01f9c7 h1:8k9xxh9MzsddPPAlPFnG1NPXR2+WO7LdHwbMHXFYj0E=
421-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260220110856-b6523f01f9c7/go.mod h1:qEUp3kyKkocqvf7xErppgAtkmudZR1TMaQUvDTGYCUI=
420+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260227101327-7478579b5f25 h1:ofIzdQmqaiI7fzvBvKedoorj2kxvqmJXlY8BMe4d3Ik=
421+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260227101327-7478579b5f25/go.mod h1:P9ZywyTQzp+WsNmeb4IiMQOdVb++eQUD5oXd18LRVj8=
422422
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260218080258-3bf55ed18973 h1:fOlWUGkCuujnIcE3166gpTdvicwv1wAZhLrfbm+f6rY=
423423
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260218080258-3bf55ed18973/go.mod h1:GDveG1xAoiM12JlSx8RE0OcJ6Ov+xcmpmGv84we3pMA=
424424
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260202100913-d9ee9476845a h1:lTOAhUjKcOmM/0Kbj4V+I/VHPlW7YNAhIEVpGnCM5mI=

0 commit comments

Comments
 (0)