aiida-vasp / parsevasp

A general parser for VASP
MIT License
13 stars 13 forks source link

ipython issue #103

Closed atztogo closed 2 years ago

atztogo commented 2 years ago

Using parsevasp on ipython, I get noisy message when I push tab key, for example, as follows.

In [1]: from parsevasp.poscar import Poscar

In [2]: poscar = Poscar(file_path="POSCAR-unitcell")

In [3]: poscar.DEBUG:parso.cache:pickle loaded: /home/togo/phelel/parsevasp/parsevasp/poscar.py
DEBUG:parso.cache:pickle loaded: /home/togo/.miniconda/envs/phelel/lib/python3.8/site-packages/jedi/third_party/typeshed/stdlib/2and3/builtins.pyi
DEBUG:parso.cache:pickle loaded: /home/togo/phelel/parsevasp/parsevasp/__init__.py
DEBUG:parso.cache:pickle loaded: /home/togo/phelel/parsevasp/parsevasp/base.py
DEBUG:parso.cache:pickle loaded: /home/togo/.miniconda/envs/phelel/lib/python3.8/abc.py
DEBUG:parso.cache:pickle loaded: /home/togo/.miniconda/envs/phelel/lib/python3.8/site-packages/jedi/third_party/typeshed/stdlib/3/abc.pyi

This can be quiet following logging setting (see https://github.com/ipython/ipython/issues/10946)

I think parsevasp doesn't assume to be used from ipython, but in fact, it is useful.

Watch the code, e.g.,

https://github.com/aiida-vasp/parsevasp/blob/573842a96dd3e25b1e8dc53838f3e7db988d356d/parsevasp/base.py#L46-L50

where when logger is not given, logger with DEBUG level is automatically set. But I think this is not appropriate setting, because DEBUG level is better to be set intentionally in my opinion.

My question is how much parsevasp relies on this behaviour? Otherwise, I expect the default behaviour to be no logger setting.

Could anyone give me any comment?

zhubonan commented 2 years ago

I think the issue is that

     logging.basicConfig(level=logging.DEBUG) 

make the global root logger at the DEBUG level. So you get all DEBUG level logs from other packages that uses the root logger directly.

To properly enable DEBUG level logging for parsevasp (e.g. self._logger), we should set its own logger and handler at DEBUG level.

espenfl commented 2 years ago

To properly enable DEBUG level logging for parsevasp (e.g. self._logger), we should set its own logger and handler at DEBUG level.

I fully agree on this. We basically force all logging events that use the default logger to be on the DEBUG level.

zhubonan commented 2 years ago

I have made a PR #104

atztogo commented 2 years ago

Thanks @zhubonan and @espenfl. I have to learn more about logging. Thanks @zhubonan your PR, and your comment gave me motivation to start learning logging.

espenfl commented 2 years ago

@atztogo Can you check how it is now with the recent update from PR #104?

atztogo commented 2 years ago

It's fixed. Thanks.