tkeech1 / streamweb

A basic blog/portfolio web site template based on Streamlit.
MIT License
0 stars 0 forks source link

ValueError: Unable to configure handler 'file_handler' #1

Open okoliechykwuka opened 1 year ago

okoliechykwuka commented 1 year ago

I get the below error when I run streamlit run layout_clean_sidebar.py -- prd. The error is coming from line 18 in metrics.py

logging.config.dictConfig(config)

How can I fix this

Traceback (most recent call last):
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 593, in get_or_create_cached_value
    return_value = _read_from_cache(
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 350, in _read_from_cache
    raise e
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 335, in _read_from_cache
    return _read_from_mem_cache(
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 252, in _read_from_mem_cache
    raise CacheKeyNotFoundError("Key not found in mem cache")
streamlit.runtime.legacy_caching.caching.CacheKeyNotFoundError: Key not found in mem cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\config.py", line 565, in configure
    handler = self.configure_handler(handlers[name])
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\config.py", line 746, in configure_handler
    result = factory(**kwargs)
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1169, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1201, in _open
    return open_func(self.baseFilename, self.mode,
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\home\\python\\streamweb-logs\\perf_metrics.log'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamweb\streamweb\layout_clean_sidebar.py", line 101, in <module>
    main(sws, content_id)
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamweb\streamweb\layout_clean_sidebar.py", line 71, in main
    home(st, sws)
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamweb\streamweb\utils\metrics.py", line 45, in measure_time
    perf_logger = get_perf_logger()
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 627, in wrapped_func
    return get_or_create_cached_value()
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamlit_app\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 611, in get_or_create_cached_value
    return_value = non_optional_func(*args, **kwargs)
  File "C:\Users\Glodaris\OneDrive\Desktop\streamlit\streamweb\streamweb\utils\metrics.py", line 18, in get_perf_logger
    logging.config.dictConfig(config)
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\config.py", line 810, in dictConfig
    dictConfigClass(config).configure()
  File "C:\Users\Glodaris\AppData\Local\Programs\Python\Python310\lib\logging\config.py", line 572, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'file_handler'
maticos-dev commented 1 month ago

Open the file being called by metrics.py (by the get_perf_logger() function) called "perf_logging.yaml". In this file, the path to perf_metrics.log in the handler's "filename" parameter is incorrect.

Create a new perf_metrics.log somewhere in the streamweb folder, get its path on your system, and paste the path into the filename parameter on the "perf_logging.yaml" file.