Skip to content

Commit ce05ac3

Browse files
authored
Merge branch 'main' into rt-skills-command
2 parents 9aea095 + 069e33e commit ce05ac3

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

artifactory/commands/helm/helmcommand.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (hc *HelmCommand) collectBuildInfoIfNeeded() error {
194194
log.Debug("Skipping build info for ", hc.cmdName)
195195
return nil
196196
}
197-
log.Info("Collecting build info for executed helm ", hc.cmdName, "command")
197+
log.Info("Collecting build info for executed helm", hc.cmdName, "command")
198198
buildName, err := hc.buildConfiguration.GetBuildName()
199199
if err != nil {
200200
return errorutils.CheckError(err)

artifactory/commands/huggingface/huggingFaceDownload.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (hfd *HuggingFaceDownload) CollectDependenciesForBuildInfo() error {
122122
})
123123
}
124124
ctx.BuildInfo.Modules[0].Dependencies = dependencies
125+
removeDuplicateDependencies(ctx.BuildInfo)
125126
return SaveBuildInfo(ctx)
126127
}
127128

@@ -184,6 +185,12 @@ func NewHuggingFaceDownload() *HuggingFaceDownload {
184185
return &HuggingFaceDownload{}
185186
}
186187

188+
// SetCommandName sets the command name for the download command
189+
func (hfd *HuggingFaceDownload) SetCommandName(commandName string) *HuggingFaceDownload {
190+
hfd.name = commandName
191+
return hfd
192+
}
193+
187194
// SetRepoId sets the repository ID for the download command
188195
func (hfd *HuggingFaceDownload) SetRepoId(repoId string) *HuggingFaceDownload {
189196
hfd.repoId = repoId

artifactory/commands/huggingface/huggingFaceUpload.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (hfu *HuggingFaceUpload) CollectArtifactsForBuildInfo() error {
123123
})
124124
}
125125
ctx.BuildInfo.Modules[0].Artifacts = artifacts
126+
removeDuplicateArtifacts(ctx.BuildInfo)
126127
return SaveBuildInfo(ctx)
127128
}
128129

@@ -197,6 +198,12 @@ func NewHuggingFaceUpload() *HuggingFaceUpload {
197198
return &HuggingFaceUpload{}
198199
}
199200

201+
// SetCommandName sets the command name for the upload command
202+
func (hfu *HuggingFaceUpload) SetCommandName(commandName string) *HuggingFaceUpload {
203+
hfu.name = commandName
204+
return hfu
205+
}
206+
200207
// SetFolderPath sets the folder path to upload for the upload command
201208
func (hfu *HuggingFaceUpload) SetFolderPath(folderPath string) *HuggingFaceUpload {
202209
hfu.folderPath = folderPath

artifactory/commands/huggingface/utils.go

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func GetBuildInfoContext(buildConfig *buildUtils.BuildConfiguration, commandName
194194
if !isCollectBuildInfo {
195195
return nil, nil
196196
}
197-
log.Info("Collecting build info for executed huggingface ", commandName, " command")
197+
log.Info("Collecting build info for executed huggingface", commandName, "command")
198198
buildName, err := buildConfig.GetBuildName()
199199
if err != nil {
200200
return nil, errorutils.CheckError(err)
@@ -230,3 +230,49 @@ func SaveBuildInfo(ctx *BuildInfoContext) error {
230230
log.Info("Build info saved locally.")
231231
return nil
232232
}
233+
234+
func removeDuplicateDependencies(buildInfo *entities.BuildInfo) {
235+
if buildInfo == nil {
236+
return
237+
}
238+
for moduleIdx, module := range buildInfo.Modules {
239+
dependenciesMap := make(map[string]entities.Dependency)
240+
var dependencies []entities.Dependency
241+
for _, dependency := range module.Dependencies {
242+
sha256 := dependency.Sha256
243+
if sha256 == "" {
244+
log.Debug("Missing Sha256 for dependency: ", dependency.Id, "so, skipping it from adding into build info.")
245+
}
246+
_, exist := dependenciesMap[sha256]
247+
if sha256 != "" && !exist {
248+
dependenciesMap[sha256] = dependency
249+
dependencies = append(dependencies, dependency)
250+
}
251+
}
252+
module.Dependencies = dependencies
253+
buildInfo.Modules[moduleIdx] = module
254+
}
255+
}
256+
257+
func removeDuplicateArtifacts(buildInfo *entities.BuildInfo) {
258+
if buildInfo == nil {
259+
return
260+
}
261+
for moduleIdx, module := range buildInfo.Modules {
262+
artifactsMap := make(map[string]entities.Artifact)
263+
var artifacts []entities.Artifact
264+
for _, artifact := range module.Artifacts {
265+
sha256 := artifact.Sha256
266+
if sha256 == "" {
267+
log.Debug("Missing Sha256 for artifact: ", artifact.Name, "so, skipping it from adding into build info.")
268+
}
269+
_, exist := artifactsMap[sha256]
270+
if sha256 != "" && !exist {
271+
artifactsMap[sha256] = artifact
272+
artifacts = append(artifacts, artifact)
273+
}
274+
}
275+
module.Artifacts = artifacts
276+
buildInfo.Modules[moduleIdx] = module
277+
}
278+
}

0 commit comments

Comments
 (0)