Skip to content

Commit

Permalink
fix: Minor Tuning Results Filepath Bugfix (#453)
Browse files Browse the repository at this point in the history
**Reason for Change**:
Minor bugfix for filepath for results dir
  • Loading branch information
ishaansehgal99 authored May 31, 2024
1 parent 062ef5d commit 261877e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/tuning/preset-tuning.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ func PrepareOutputDir(outputDir string) (string, error) {
if outputDir == "" {
return DefaultOutputVolumePath, nil
}

cleanPath := filepath.Clean(filepath.Join(DefaultBaseDir, outputDir))
cleanPath := outputDir
if !strings.HasPrefix(cleanPath, DefaultBaseDir) {
cleanPath = filepath.Join(DefaultBaseDir, outputDir)
}
cleanPath = filepath.Clean(cleanPath)
if cleanPath == DefaultBaseDir || !strings.HasPrefix(cleanPath, DefaultBaseDir) {
klog.InfoS("Invalid output_dir specified: '%s', must be a directory. Using default output_dir: %s", outputDir, DefaultOutputVolumePath)
return DefaultOutputVolumePath, fmt.Errorf("invalid output_dir specified: '%s', must be a directory", outputDir)
Expand Down
12 changes: 12 additions & 0 deletions pkg/tuning/preset-tuning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,18 @@ training_config:
},
expectedOutputDir: "/mnt/custom/path",
},
"Output Dir already includes /mnt": {
configMap: &corev1.ConfigMap{
Data: map[string]string{
"training_config.yaml": `
training_config:
TrainingArguments:
output_dir: "/mnt/output"
`,
},
},
expectedOutputDir: DefaultOutputVolumePath,
},
"Invalid Output Dir": {
configMap: &corev1.ConfigMap{
Data: map[string]string{
Expand Down

0 comments on commit 261877e

Please sign in to comment.