pydsstools icon indicating copy to clipboard operation
pydsstools copied to clipboard

Suppress Output

Open apreucil opened this issue 2 years ago • 5 comments

Anyone know a way to suppress this output every time I am reading a variable with read_ts? Thanks! image

apreucil avatar Mar 23 '22 15:03 apreucil

I saw this was resolved in an earlier comment, but the resolution didn't work for me. I tried the suggested fix from the link below, but it had no effect. Perhaps the functionality changed? I'm using 2.2.

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

https://github.com/gyanz/pydsstools/issues/16#issuecomment-706324336

ryanjcahill avatar Mar 29 '22 20:03 ryanjcahill

Thanks Ryan, I also am on 2.2. I also tried to add the suggested code and it did not have an effect for me either. I'm using python 3.7, if that helps.

apreucil avatar Mar 30 '22 15:03 apreucil

I upgraded to python version 3.9 this morning, and installed the pydsstools for 3.9. I am no longer getting the extra output when reading the DSS files, so all good! But there may be a problem in the 3.7 distribution. Again, not a huge deal (especially since I upgraded and am no longer having the issue) but if you wanted to check into it, seems like it's isolated to the 3.7 distribution. Thanks!

apreucil avatar Apr 06 '22 15:04 apreucil

Darn, I upgraded to Python 3.9, but it didn't work for me--the messages still keep popping up.

ryanjcahill avatar Apr 27 '22 20:04 ryanjcahill

I added the logging suppression to my script and I still am seeing the output. I am running Python 3.11.3, with pydsstools==2.3 (installed from wheel pydsstools-2.3-cp311-cp311-win_amd64.whl).

import pandas as pd

from pydsstools.heclib.dss import HecDss
from pydsstools.heclib.utils import dss_logging

def get_all_ts(src, paths) -> pd.DataFrame:
    with HecDss.Open(src) as DSS:
        dss_logging.config(level=0)
        for p in paths:
            struct = DSS.read_ts(p)
            df = pd.DataFrame(
                struct.values,
                index=struct.times,
                columns=['VALUE']
            )
            df.index.name = 'TIME'
            df['PATH'] = p
            
            yield df

def get_paths(src, pattern: str = '*') -> set:
    with HecDss.Open(src) as DSS:
        dss_logging.config(level=0)
        v = DSS.getPathnameList(pattern)
    return set(v)

if __name__ == '__main__':
    paths = get_paths(FILE)
    for df in get_all_ts(FILE, paths):
        pass

Output appears as (first 10 reads):

    -----DSS---ZOPEN:  Existing File Opened,  File: 
<<<FILE>>>
                       Unit:    3;  DSS Versions - Software: 6-YO, File: 6-WC,  Library 7-IQ
WARNING:root:***Setting DSS Logging, Method = 0, Level = 0***
    -----DSS---zclose6 Unit:    3,   File: <<<FILE>>>
               Pointer Utilization: 30.90
               Number of Records: 251210
               File Size: 343301.9  Kbytes
               Percent Inactive:   0.0
               Number of Reads:    62354
    -----DSS---ZOPEN:  Existing File Opened,  File: 
<<<FILE>>>
                       Unit:    3;  DSS Versions - Software: 6-YO, File: 6-WC,  Library 7-IQ
WARNING:root:***Setting DSS Logging, Method = 0, Level = 0***
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/DL_25_PU/DELIVERY-LOSS/01JAN1930/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/SHORT_SWP_TOT_S_WHEELJPOD/DELIVERY-SHORTAGE-SWP/01JAN1920/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/S_SLUIS_SWP_2/STORAGE-ZONE/01JAN2000/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/C_FTR053/CHANNEL/01JAN1950/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/SWP_IN_SOD_CYCGW1/NDD-QAQC/01JAN1960/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/DN_72_PR4/SW_DELIVERY-NET/01JAN2000/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/SG_SACAB_CYCUP/NDD-QAQC/01JAN2020/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/I_FOLSM_FM_MED_DV__FUT__1/FORECASTED-INFLOW-MEDIAN/01JAN2000/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/FRESPILL_20DV/FLOW-DELIVERY/01JAN2020/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/SLACK__FIXD_WTPBUK_03_SU_1/SLACK/01JAN1980/1MON/L2020A/
 -----DSS---ZREAD Unit    3; Vers.    1:  /CALSIM/SHORT_NBA_LOSS/DELIVERY-SHORTAGE/01JAN1930/1MON/L2020A/
    -----DSS---zclose6 Unit:    3,   File: <<<FILE>>>
               Pointer Utilization: 30.90
               Number of Records: 251210
               File Size: 343301.9  Kbytes
               Percent Inactive:   0.0
               Number of Reads:      247

dwr-zroy avatar May 31 '23 16:05 dwr-zroy