Skip to content
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

fix: Tuning Results Filepath Bugfix #453

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading