logging levels not set comprehensively (still get INFO messages with WARNING set)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 198
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
Summary:
I set the logger level to WARNING before compiling and running a model, but I still see INFO level warning messages.
Description:
Here's a simple reproducible example consisting of a Stan program and a Python script that can go in the same directory and run as shown below.
binomial-rng.stan:
data {
int<lower=0> N;
real<lower=0, upper=1> theta;
}
generated quantities {
int<lower=0, upper=N> y = binomial_rng(N, theta);
}
bug.py
import cmdstanpy
import logging
logging.getLogger('cmdstanpy').setLevel(logging.WARNING)
N = 100
theta = 0.3
data = {'N': N, 'theta': theta}
model = cmdstanpy.CmdStanModel(stan_file = 'binomial-rng.stan')
sample = model.sample(data = data, seed=123,
iter_sampling = 10, iter_warmup = 0, chains = 1,
show_progress = False, show_console = False)
~/temp2$ python3 bug.py
14:43:39 - cmdstanpy - INFO - CmdStan start processing
14:43:39 - cmdstanpy - INFO - Chain [1] start processing
14:43:39 - cmdstanpy - INFO - Chain [1] done processing
14:43:39 - cmdstanpy - INFO - deleting tmpfiles dir: /var/folders/b3/6h4t41094vz281j7nn48ws900001jv/T/tmpojw6vov9
14:43:39 - cmdstanpy - INFO - done
The same error arises if you set logging.ERROR instead of logging.WARNING.
@WardBrian suggested the problem might be that there are several loggers being used by CmdStanPy, but only some of them are getting their level set.
Context
I would like to silence all the DEBUG and INFO level messages in the context of constructing a quarto tutorial.
Current Version:
>>> import cmdstanpy
>>> cmdstanpy.show_versions()
INSTALLED VERSIONS
---------------------
python: 3.9.4 (default, Apr 5 2021, 01:47:16)
[Clang 11.0.0 (clang-1100.0.33.17)]
python-bits: 64
OS: Darwin
OS-release: 22.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
cmdstan_folder: /Users/bcarpenter/.cmdstan/cmdstan-2.31.0
cmdstan: (2, 31)
cmdstanpy: 1.0.4
pandas: 1.4.3
xarray: 2023.1.0
tdqm: None
numpy: 1.24.1
ujson: 5.4.0
' '
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with binomial-rng.stan and bug.py, starting at the logging.getLogger('cmdstanpy') configuration and the CmdStanModel.sample call. Trace the logger names used for the reported messages and verify that setting WARNING suppresses INFO output without affecting model execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100