gyanz / pydsstools

Python library for simple HEC-DSS functions
MIT License
80 stars 36 forks source link

How to suppress prints? #16

Closed openSourcerer9000 closed 3 years ago

openSourcerer9000 commented 3 years ago

Hello, thank you for building this tool! I'm wondering how can I suppress the printed statements/warnings that it generates as I use it? I'm trying to read thousands of time series' to a pd dataframe, from the examples it seems I have to do them one at a time. Especially with all of this stuff printing out it runs very very slow.

In JupyterLab, they show up as warnings and print for miles down the notebook, but with warnings.catch_warnings(): warnings.simplefilter("ignore") doesn't get rid of them. Any help would be appreciated, thanks!

This is the warning I'm getting, it doesn't see mto affect the results: WARNING:root:-----DSS--- ztsRetrieveReg Warning: Incompatible DSS version This function is only compatible with version 7 DSS files This file is version 0

gyanz commented 3 years ago

I suggest including following code at the beginning of file or code to suppress the print statements:

from pydsstools.heclib.utils import dss_logging
dss_logging.config(level='None')

The level parameter can be None, Error, Critical, General, Info, Debug or Diagnostic.

openSourcerer9000 commented 3 years ago

Hm, I'm trying that and it's still printing:

WARNING:root:Setting DSS Logging, Method = 0, Level = 0

WARNING:root:Setting DSS Logging, Method = 0, Level = 0

WARNING:root:Setting DSS Logging, Method = 0, Level = 0

-----DSS---ZOPEN:  Existing File Opened,  File: C:\Users\openSourcerer\CDT.dss

                   Unit:    3;  DSS Versions - Software: 6-YN, File: 6-KE,  Library 7-HS

-----DSS---ZREAD Unit 3; Vers. 1: //72106/PRECIP-INC/01JUN2001/15MIN//

-----DSS---ZREAD Unit 3; Vers. 1: //72774/PRECIP-INC/01JUN2001/15MIN//

-----DSS---ZREAD Unit 3; Vers. 1: //74436/PRECIP-INC/01JUN2001/15MIN//

-----DSS---ZREAD Unit 3; Vers. 1: //74455/PRECIP-INC/01JUN2001/15MIN//

gyanz commented 3 years ago

This issue has been resolved in version 1.8.

JoeShmoJo commented 1 month ago

I have the latest version recently installed from pip but the logging suppression is not working for me. I'm getting pages of logging and warnings that I'm using incompatible DSS versions (I'm using DSS 6, not 7) but the DSS reading and writing seems to be working fine. I see this issue is a couple years old. Has there been any recent fixes?