Hi @Adrien_Treuille, that sounds great. Here’s a code snippet using pyopenms and an exemplary mzML file 1min.mzML
as data source.
from pyopenms import MSExperiment
# path to the 1min.mzML file as string, relative should work as well
path_to_mzml_file = ...
exp = MSExperiment()
MzFile().load(path_to_mzml_file, exp)
# exp contains the object instance of relevance now
When I run hash(exp)
:
TypeError: unhashable type: 'pyopenms.pyopenms_5.MSExperiment'
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\ScriptRunner.py", line 311, in _run_script exec(code, module.__dict__)
File "C:\Users\Florian\gitlab\data-explorer\app.py", line 180, in <module> main()
File "C:\Users\Florian\gitlab\data-explorer\app.py", line 39, in main hash(exp)
WHen using @st.cache()
the full trace is:
Streamlit cannot hash an object of type <class 'pyopenms.pyopenms_5.MSExperiment'>.
More information: to prevent unexpected behavior, Streamlit tries to detect mutations in cached objects defined in your local files so it can alert you when the cache is used incorrectly. However, something went wrong while performing this check.
This error can occur when your virtual environment lives in the same folder as your project, since that makes it hard for Streamlit to understand which files it should check. If you think that's what caused this, please add the following to ~/.streamlit/config.toml:
[server]
folderWatchBlacklist = ['foldername']
...where foldername is the relative or absolute path to the folder where you put your virtual environment.
Otherwise, please file a bug here.
To stop this warning from showing in the meantime, try one of the following:
Preferred: modify your code to avoid using this type of object.
Or add the argument allow_output_mutation=True to the st.cache decorator.
Streamlit failed to hash an object of type <class 'tuple'>.
<SAME-HINT-AS-ABOVE>
Streamlit failed to hash an object of type <class 'list'>.
<SAME-HINT-AS-ABOVE>
TypeError: object supporting the buffer API required
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\ScriptRunner.py", line 311, in _run_script exec(code, module.__dict__)
File "C:\Users\Florian\gitlab\data-explorer\app.py", line 180, in <module> main()
File "C:\Users\Florian\gitlab\data-explorer\app.py", line 51, in main spectra_dfs = load_spectra(exp)
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\caching.py", line 560, in wrapped_func return get_or_set_cache()
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\caching.py", line 517, in get_or_set_cache args_hasher.update([args, kwargs])
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\hashing.py", line 209, in update self._update(self.hasher, obj, context)
File "c:\users\florian\.virtualenvs\data-explorer-_mha6hq8\lib\site-packages\streamlit\hashing.py", line 241, in _update hasher.update(b)