I added a .streamlit/config.toml today and got the following error. This error also occurs when I add e.g. empty line in the .py. So it can’t be the code, it was working exactly as it is before.
KeyError: 159
Traceback:
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “/mount/src/stroke_probability/Stroke_Proba.py”, line 66, in
svm1, svm2, logit1, logit2, nbc1, nbc2, rf1, rf2, errGBR = loadAllModels(URL)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py”, line 211, in wrapper
return cached_func(*args, **kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py”, line 240, in call
return self._get_or_create_cached_value(args, kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py”, line 266, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py”, line 320, in _handle_cache_miss
computed_value = self._info.func(*func_args, **func_kwargs)
File “/mount/src/stroke_probability/Stroke_Proba.py”, line 58, in loadAllModels
joblib.load(
File “/home/adminuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py”, line 577, in load
obj = _unpickle(fobj)
File “/home/adminuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py”, line 506, in _unpickle
obj = unpickler.load()
File “/usr/local/lib/python3.9/pickle.py”, line 1212, in load
dispatchkey[0]
of course you get everything. As I said, I have not changed the code at all. I had the problem once when I inserted new empty lines to make the code a bit clearer. When I reverted that everything worked again.
Upon checking the config file from the repository you provided, it appears to be correctly formatted.
From what I gather, you mentioned an issue that occured after adding an empty line in the .py file. However, simply adding an empty line in the main Py file, Stroke_Proba.py, shouldn’t typically introduce any bugs.
A practical approach would be to:
Revert to a previous version of your repo, to a point when everything was working as expected.
Then, compare the two versions to pinpoint any differences.
Additionally, the traceback you shared earlier indicates a KeyError when attempting to load a model via joblib. Could you please double-check if the path to the model file is accurate?