-
Notifications
You must be signed in to change notification settings - Fork 282
Feature/rteco 814 implement build info collection for hugging face #3352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
naveenku-jfrog
wants to merge
5
commits into
jfrog:master
Choose a base branch
from
naveenku-jfrog:feature/RTECO-814-Implement-Build-Info-collection-for-Hugging-Face
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d7bc6c9
Addressing go sec failures
naveenku-jfrog 7e8ad5a
Addressing go sec failures
naveenku-jfrog 1fec362
Merge branch 'jfrog:master' into fix/Fixing-go-sec-failures
naveenku-jfrog e969f6b
Addressing go sec failures
naveenku-jfrog 8984f4a
Added build info collection logic for hugging face download and uploa…
naveenku-jfrog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import ( | |
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/golang" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle" | ||
| helmcmd "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/helm" | ||
| huggingfaceCommands "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/huggingface" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/mvn" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/npm" | ||
| containerutils "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer" | ||
|
|
@@ -58,6 +59,7 @@ import ( | |
| "github.com/jfrog/jfrog-cli/docs/buildtools/gopublish" | ||
| gradledoc "github.com/jfrog/jfrog-cli/docs/buildtools/gradle" | ||
| "github.com/jfrog/jfrog-cli/docs/buildtools/gradleconfig" | ||
| "github.com/jfrog/jfrog-cli/docs/buildtools/huggingface" | ||
| mvndoc "github.com/jfrog/jfrog-cli/docs/buildtools/mvn" | ||
| "github.com/jfrog/jfrog-cli/docs/buildtools/mvnconfig" | ||
| "github.com/jfrog/jfrog-cli/docs/buildtools/npmcommand" | ||
|
|
@@ -475,6 +477,17 @@ func GetCommands() []cli.Command { | |
| Category: buildToolsCategory, | ||
| Action: twineCmd, | ||
| }, | ||
| { | ||
| Name: "hugging-face", | ||
| Aliases: []string{"hf"}, | ||
| Flags: cliutils.GetCommandFlags(cliutils.HuggingFace), | ||
| HelpName: corecommon.CreateUsage("hugging-face", huggingface.GetDescription(), huggingface.Usage), | ||
| Description: huggingface.GetDescription(), | ||
| UsageText: huggingface.GetArguments(), | ||
| Hidden: true, | ||
| Action: huggingFaceCmd, | ||
| Category: buildToolsCategory, | ||
| }, | ||
| }) | ||
| return decorateWithFlagCapture(cmds) | ||
| } | ||
|
|
@@ -1115,6 +1128,87 @@ func loginCmd(c *cli.Context) error { | |
| return nil | ||
| } | ||
|
|
||
| func huggingFaceCmd(c *cli.Context) error { | ||
| if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil { | ||
| return err | ||
| } | ||
| if c.NArg() < 1 { | ||
| return cliutils.WrongNumberOfArgumentsHandler(c) | ||
| } | ||
| serverDetails, err := coreConfig.GetDefaultServerConf() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| args := cliutils.ExtractCommand(c) | ||
| cmdName, hfArgs := getCommandName(args) | ||
| hfArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(hfArgs) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| switch cmdName { | ||
| case "u", "upload": | ||
| return huggingFaceUploadCmd(c, hfArgs, serverDetails, buildConfiguration) | ||
| case "d", "download": | ||
| return huggingFaceDownloadCmd(c, hfArgs, serverDetails, buildConfiguration) | ||
| default: | ||
| return errors.New("Wrong command: " + cmdName) | ||
| } | ||
| } | ||
|
|
||
| func huggingFaceUploadCmd(c *cli.Context, hfArgs []string, serverDetails *coreConfig.ServerDetails, buildConfiguration *build.BuildConfiguration) error { | ||
| // Upload requires folderPath and repoID | ||
| if len(hfArgs) < 2 { | ||
| return cliutils.PrintHelpAndReturnError("Folder path and repository ID are required.", c) | ||
| } | ||
| folderPath := hfArgs[0] | ||
| if folderPath == "" { | ||
| return cliutils.PrintHelpAndReturnError("Folder path cannot be empty.", c) | ||
| } | ||
| repoID := hfArgs[1] | ||
| if repoID == "" { | ||
| return cliutils.PrintHelpAndReturnError("Repository ID cannot be empty.", c) | ||
| } | ||
|
Comment on lines
+1160
to
+1170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess last two cases are redundant |
||
| revision := "" | ||
| if c.String("revision") != "" { | ||
| revision = c.String("revision") | ||
| } | ||
| repoType := c.String("repo-type") | ||
| if repoType == "" { | ||
| repoType = "model" | ||
| } | ||
| huggingFaceUploadCmd := huggingfaceCommands.NewHuggingFaceUpload().SetFolderPath(folderPath).SetRepoId(repoID).SetRepoType(repoType).SetRevision(revision).SetServerDetails(serverDetails).SetBuildConfiguration(buildConfiguration) | ||
| return commands.Exec(huggingFaceUploadCmd) | ||
| } | ||
|
|
||
| func huggingFaceDownloadCmd(c *cli.Context, hfArgs []string, serverDetails *coreConfig.ServerDetails, buildConfiguration *build.BuildConfiguration) error { | ||
| // Download requires repoID | ||
| if len(hfArgs) < 1 { | ||
| return cliutils.PrintHelpAndReturnError("Model/Dataset name is required.", c) | ||
| } | ||
| repoID := hfArgs[0] | ||
| if repoID == "" { | ||
| return cliutils.PrintHelpAndReturnError("Model/Dataset name cannot be empty.", c) | ||
| } | ||
| revision := "" | ||
| if c.String("revision") != "" { | ||
| revision = c.String("revision") | ||
| } | ||
| etagTimeout := 86400 | ||
| if c.String("etag-timeout") != "" { | ||
| var err error | ||
| etagTimeout, err = strconv.Atoi(c.String("etag-timeout")) | ||
| if err != nil { | ||
| return errorutils.CheckErrorf("invalid etag-timeout value: %s", c.String("etag-timeout")) | ||
| } | ||
| } | ||
| repoType := c.String("repo-type") | ||
| if repoType == "" { | ||
| repoType = "model" | ||
| } | ||
| huggingFaceDownloadCmd := huggingfaceCommands.NewHuggingFaceDownload().SetRepoId(repoID).SetRepoType(repoType).SetRevision(revision).SetEtagTimeout(etagTimeout).SetServerDetails(serverDetails).SetBuildConfiguration(buildConfiguration) | ||
| return commands.Exec(huggingFaceDownloadCmd) | ||
| } | ||
|
|
||
| func dockerScanCmd(c *cli.Context, imageTag string) error { | ||
| if show, err := cliutils.ShowGenericCmdHelpIfNeeded(c, c.Args(), securityCLI.DockerScanCmdHiddenName); show || err != nil { | ||
| return err | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package huggingface | ||
|
|
||
| var Usage = []string{ | ||
| "hugging-face upload <folder-path> <repo-id> [command options]", | ||
| "hugging-face download <repo-id> [command options]", | ||
| } | ||
|
|
||
| func GetDescription() string { | ||
| return "Run Hugging Face commands with Artifactory integration." | ||
| } | ||
|
|
||
| func GetArguments() string { | ||
| return ` hugging-face sub-command | ||
| upload <folder-path> <repo-id> | ||
| Upload a folder to Hugging Face repository. | ||
| download <repo-id> | ||
| Download from Hugging Face repository. | ||
|
|
||
| Examples: | ||
| - jf hugging-face upload ./models my-org/my-model | ||
| - jf hf download my-org/my-model --revision=main` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as I understood, artifactory does not support commands other than upload or download, then for default case: