Jacinto Velasco commited on
Commit 路
c03ab4a
1
Parent(s): 7d39d3d
Silenciar el ruido de streamlit en las pruebas de interfaz
Browse files- pruebas_interfaz.py +25 -1
pruebas_interfaz.py
CHANGED
|
@@ -27,7 +27,30 @@ os.environ.setdefault("STREAMLIT_GLOBAL_DEVELOPMENT_MODE", "false")
|
|
| 27 |
|
| 28 |
from streamlit.testing.v1 import AppTest # noqa: E402
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
ESPERA = 180 # segundos: algunos estudios simb贸licos tardan
|
| 33 |
|
|
@@ -36,6 +59,7 @@ fallos = []
|
|
| 36 |
|
| 37 |
def arranca():
|
| 38 |
app = AppTest.from_file("app.py", default_timeout=ESPERA)
|
|
|
|
| 39 |
app.run()
|
| 40 |
return app
|
| 41 |
|
|
|
|
| 27 |
|
| 28 |
from streamlit.testing.v1 import AppTest # noqa: E402
|
| 29 |
|
| 30 |
+
|
| 31 |
+
class _SinRuido(logging.Filter):
|
| 32 |
+
"""Descarta el aviso de 芦missing ScriptRunContext禄 y deja pasar el resto."""
|
| 33 |
+
|
| 34 |
+
def filter(self, registro):
|
| 35 |
+
return "missing ScriptRunContext" not in registro.getMessage()
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def _calla_streamlit():
|
| 39 |
+
"""El filtro va en los MANEJADORES, no en el logger.
|
| 40 |
+
|
| 41 |
+
El aviso lo emite un logger hijo (鈥criptrunner_utils.script_run_context) y
|
| 42 |
+
un filtro puesto en el logger padre no se aplica a los hijos; en cambio los
|
| 43 |
+
manejadores del padre s铆 los atienden, y ah铆 el filtro funciona. Se vuelve
|
| 44 |
+
a llamar tras cada ejecuci贸n porque streamlit a帽ade manejadores por el
|
| 45 |
+
camino.
|
| 46 |
+
"""
|
| 47 |
+
for nombre in ("streamlit", ""):
|
| 48 |
+
registrador = logging.getLogger(nombre)
|
| 49 |
+
for manejador in registrador.handlers:
|
| 50 |
+
manejador.addFilter(_SinRuido())
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
_calla_streamlit()
|
| 54 |
|
| 55 |
ESPERA = 180 # segundos: algunos estudios simb贸licos tardan
|
| 56 |
|
|
|
|
| 59 |
|
| 60 |
def arranca():
|
| 61 |
app = AppTest.from_file("app.py", default_timeout=ESPERA)
|
| 62 |
+
_calla_streamlit() # streamlit a帽ade manejadores al arrancar
|
| 63 |
app.run()
|
| 64 |
return app
|
| 65 |
|