-
Notifications
You must be signed in to change notification settings - Fork 30
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: Fix Path Resolution in process_log_dir_replacements
Function
#279
Conversation
Signed-off-by: brf153 <153hsb@gmail.com>
process_log_dir_replacements
Function
Thank you for your contribution. Before we consider merging, I would like to know if you ran into functional errors that necessitated this PR or if this was more of a stylistic concern to clean up how the path was displayed. Let's discuss in #278 |
@brf153 do you want to include in this PR the test you shared in |
Thank you so much, @jwmatthews ! I'm really glad the test example helped clarify things. Regarding the test you mentioned from #278, I've actually set up a separate branch just for tests. I'd prefer to add the tests from that branch if that's alright with you. Please let me know if that works. |
Works for me |
We will need to make a small change before we can merge this; as of now, the log directory is being created 1 lever higher in the hierarchy than we want. I tested this via My kai checkout is at: I ran Example from console logging output: I also tried with something a little odder just to verify behavior. Confirmed the log directory is again going a level higher in heirarchy than expected I made the below tweak to correct this
Tested with podman compose to confirm logging to disk is still OK with the above tweak and looks good |
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 of now, this is creating the logs directory 1 level higher than we want.
kai/kai_logging.py
Outdated
"$pwd", os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") | ||
) | ||
current_directory = os.getcwd() | ||
kai_project_directory = os.path.abspath(os.path.join(current_directory, "..")) |
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.
We need to change this and get rid of the "..", that was needed in past when we were basing the directory to the location of __file__
.
Signed-off-by: brf153 <153hsb@gmail.com>
@jwmatthews made the required changes |
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.
I tested both local dev and podman compose and verified logs are going to right location
Summary
This PR closes #278. It addresses an issue with the
process_log_dir_replacements
function, which is responsible for replacing the $pwd placeholder in log directory paths with the path to the Kai project directory. The original function returned paths with redundant components and did not correctly resolve relative paths.Issue
The original function produced paths with incorrect or redundant components, such as /home/k8smaster/Desktop/kai/kai/..//logs, leading to errors and misconfiguration in the log directory paths.
Changes Made
Function Update: Updated the process_log_dir_replacements function to:
Replace $pwd with the path to the Kai project directory, one level up from the current working directory.
Normalize the resulting path to remove redundant components and resolve relative path issues.