Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

logging levels not set comprehensively (still get INFO messages with WARNING set)

Open
#665 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

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.

Description

bug
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

' '
Dominant language
Python
Stars
198
Forks
81
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stan-dev/cmdstanpy

All issues in stan-dev/cmdstanpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.