statsforecast icon indicating copy to clipboard operation
statsforecast copied to clipboard

Importing statsforecast supersedes any logging config

Open JeroenPeterBos opened this issue 1 year ago • 2 comments

Describe the bug A best practice in python is to setup the main python file in the following way:

<imports>

...

if __name__ == '__main__':
    <setup logging>
    <start program>

However, importing statsforecast will supersede any logging setup defined in this best-practice way.

To Reproduce Steps to reproduce the behavior, run the following commands, with the following contents for test_log.py:

conda create -n tmp python=3.8 pip
conda activate tmp
pip install statsforecast==1.1.1
python test_log.py

Contents of test_log.py:

import logging
import statsforecast

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    logging.info("Hello World")

Expected behavior For logs to appear in the terminal. This does not happen because statsforecast makes its own call to logging.basicConfig in the core.py file, which is a bad practice for a distributed package.

Additional context I will submit a PR shortly.

JeroenPeterBos avatar Oct 19 '22 15:10 JeroenPeterBos

Thanks for the comments @JeroenPeterBos

This is the contributing guide, if you find any problem feel free to reach us.

kdgutier avatar Oct 19 '22 15:10 kdgutier

#275

JeroenPeterBos avatar Oct 24 '22 10:10 JeroenPeterBos

Fixed in #275

AzulGarza avatar Dec 06 '22 05:12 AzulGarza