Skip to content

Conversation

rhsouza
Copy link
Contributor

@rhsouza rhsouza commented Feb 1, 2024

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

custom path for logging, if not given, will use local logs.log
@moezali1 moezali1 requested a review from Yard1 February 2, 2024 00:06
@Yard1
Copy link
Member

Yard1 commented Mar 3, 2024

Thanks!

@Yard1 Yard1 merged commit 6ee43ce into pycaret:master Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make logging configurable
2 participants