baal-org / baal

Bayesian active learning library for research and industrial usecases.
https://baal.readthedocs.io
Apache License 2.0
854 stars 84 forks source link

Structlog log.warnings() error #284

Closed arthur-thuy closed 3 months ago

arthur-thuy commented 3 months ago

Describe the bug The line log.warnings("Not enough values, return random") (in baal/active/heuristics/stochastics.py throws an error:

File "/home/abthuy/anaconda3/envs/qdet_active/lib/python3.11/site-packages/baal/active/active_loop.py", line 87, in step
    to_label, uncertainty = self.heuristic.get_ranks(probs)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abthuy/anaconda3/envs/qdet_active/lib/python3.11/site-packages/baal/active/heuristics/stochastics.py", line 50, in get_ranks
    log.warnings("Not enough values, return random")
    ^^^^^^^^^^^^
  File "/home/abthuy/anaconda3/envs/qdet_active/lib/python3.11/site-packages/structlog/_config.py", line 391, in __getattr__
    return getattr(bl, name)
           ^^^^^^^^^^^^^^^^^
AttributeError: 'BoundLogger' object has no attribute 'warnings'. Did you mean: 'warning'?

To Reproduce

>>> import structlog
>>> print(structlog.__version__)
21.5.0
>>> log = structlog.get_logger(__name__)
>>> log.warnings("Not enough values, return random")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/abthuy/anaconda3/envs/qdet_active/lib/python3.11/site-packages/structlog/_config.py", line 393, in __getattr__
    return getattr(bl, name)
           ^^^^^^^^^^^^^^^^^
AttributeError: 'BoundLoggerFilteringAtNotset' object has no attribute 'warnings'. Did you mean: 'warning'?
>>> log.warning("Not enough values, return random")
2024-04-04 09:15.04 [warning  ] Not enough values, return random

Expected behavior Should it simply be log.warning("Not enough values, return random") (without "s")?

Note that the Baal output above comes from a virtual environment with structlog=22.1.0, while the toy example is run in a virtual environment with structlog=21.5.0. Why does the pyproject.toml set the dependency structlog = "^21.1.0"? I want to use the structlog.stdlib.recreate_defaults() function which was added in version 22.1.0.

Version (please complete the following information):

Dref360 commented 3 months ago

Good catch! Not sure why I havent got this before. Will make a PR before eod and publish a patch version.

As for structlog version, I'll see if I can bump it

Dref360 commented 3 months ago

Fixed in 1.9.2