Custom path for logging (logs.log) #3902
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue or bug
The logs.log file is automatically generated in the import script directory (by pycaret/internal/logging.py). This creates problems when the directory is not writable, like AWS Lambda.
I particularly have problems using it directly in the lambda with a container, as the only free directory to write to is '/tmp'.
This update is correctly saving to the desired path.
I found other reports like issue #1057.
Closes #1057
Describe the changes you've made
I created a new variable 'logPath' and assigned it an environment variable (PYCARET_CUSTOM_LOGGING_PATH), similar to the one already used for the log level (PYCARET_CUSTOM_LOGGING_LEVEL).
I changed the name of the file ‘logs.log’ to this variable, which takes the path informed in the environment variable and if it doesn’t exist, it continues as ‘logs.log’
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
After updating the function, I ran pycaret update and provided a new path to the 'PYCARET_CUSTOM_LOGGING_PATH' environment variable.
I imported the functions 'from pycaret.regression import load_model, predict_model' and verified the log file creation as desired.
Describe if there is any unusual behaviour of your code(Write
NA
if there isn't)NA
Checklist: