Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch off dask client warnings

Dask client spams warnings in my Jupyter Notebook output. Is there a way to switch off dask warnings?

Warning text look like this: "distributed.worker - WARNING - Memory use is high but worker has no data to store to disk. Perhaps some other process is leaking memory? Process memory: 3.16 GB -- Worker memory limit: 4.20 GB"

The problem appear after these code:

import pandas as pd
from sqlalchemy import create_engine, MetaData
from sqlalchemy import select, insert, func
import dask.dataframe as dd

from dask.distributed import Client
client = Client(n_workers=4, threads_per_worker=4, processes=False)

engine = create_engine(uri)
meta_core = MetaData()
meta_core.reflect(bind=engine)

table = meta_core.tables['table']

dd_main = dd.read_sql_table(
    table=table,
    uri=uri,
    index_col='id'
)

dd_main.head()

After executing the chunk above, I get a lot of these warnings in every Jupyter cell, so I can't even find my actual output.

like image 833
Andrey Goloborodko Avatar asked Mar 04 '23 14:03

Andrey Goloborodko


2 Answers

You can pass a logging level to the Client constructor like the following:

client = Client(..., silence_logs='error')
like image 110
MRocklin Avatar answered Mar 15 '23 23:03

MRocklin


I had to use a variation on MRocklin's answer:

import logging

client = Client(..., silence_logs=logging.ERROR)

The string "error" is not recognized by python's logging, which uses constants. An alternative is to pass the numerical value of the constant directly instead (here logging.ERROR == 50). See logging levels.

like image 42
ian-whitestone Avatar answered Mar 15 '23 23:03

ian-whitestone