Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#665 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Riproduci il report con binomial-rng.stan e bug.py, iniziando dalla configurazione di logging.getLogger('cmdstanpy') e dalla chiamata a CmdStanModel.sample. Traccia i nomi dei logger utilizzati per i messaggi segnalati e verifica che l'impostazione di WARNING sopprima l'output INFO senza influire sull'esecuzione del modello.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

' '
Lingua principale
Python
Stelle
198
Fork
81
Merge medio
6g 5h
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stan-dev/cmdstanpy

Tutte le issue di stan-dev/cmdstanpy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.