-
Notifications
You must be signed in to change notification settings - Fork 187
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
chore: load cpu architecture dependent models #1800
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Huamin Chen <[email protected]>
🤖 SeineSailor Here is a concise summary of the pull request changes: Summary: This pull request, "chore: load cpu architecture dependent models", enables loading of CPU architecture-dependent models by introducing a Key Modifications:
Impact: These changes will allow the codebase to load power models based on CPU architecture, potentially affecting the behavior of the code when loading power models. Observations/Suggestions:
|
cpuArch = strings.TrimSpace(cpuArch) | ||
fullPath := fmt.Sprintf(`/var/lib/kepler/data/%s/model_weight/%s_%sModel.json`, cpuArch, energySource, modelOutputType) | ||
// if the model does not exist, return the default model | ||
if _, err := os.Stat(fullPath); os.IsNotExist(err) { |
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.
Won't this result in a possible race condition? If you can guarantee that after the os.Stat the file exists, then ignore this comment.
return fmt.Sprintf(`/var/lib/kepler/data/model_weight/%s_%sModel.json`, energySource, modelOutputType) | ||
func GetDefaultPowerModelURL(modelOutputType, energySource, cpuArch string) string { | ||
// strip white space or new line from cpuArch | ||
cpuArch = strings.TrimSuffix(cpuArch, "\n") |
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.
TrimSpace should remove \n characters and white space, so you can remove this line
cpuArch = strings.TrimSpace(cpuArch) | ||
fullPath := fmt.Sprintf(`/var/lib/kepler/data/%s/model_weight/%s_%sModel.json`, cpuArch, energySource, modelOutputType) | ||
// if the model does not exist, return the default model | ||
if _, err := os.Stat(fullPath); os.IsNotExist(err) { |
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.
On a minor note, os.isNotExist(err) might be misleading as os.Stat can return other types of errors which is not the same as a file/model not existing.
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.
these files shouldn't change at all 🤔
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.
LGTM! but requesting change to remove the ebpf file changes.
This is to prepare for coming CPU dependent models