__qualname__ error when using advanced caching

Hi all!

I’m trying to cache a function generating a pandas dataframe (, which includes an object of the module Bio.pairwise2 of the Bio package. I tried to manually define the hash function for the UnhashableTypeError for the unsupported object which results in a new AttributeError: qualname

This is my first time using caching, so I could imagine a simple answer such as “mutable objects are not hashable”. Is this the case here?

The app: https://share.streamlit.io/jacobhanimann/isoaligner/main/Webinterface.py

Thanks for the help!
Cheers, Jacob

Hi @JacobHanimann,

Thank you for sharing with the Streamlit community!

As the error message notes, you can supply your own function to hash objects of type Bio.pairwise2.alignment_function. The syntax for this looks like the following:

@st.cache(hash_funcs={FooType: hash_foo_type})def my_cached_func(a, b):…

where FooType is the type Streamlit was unable to hash (in this case Bio.pairwise2.alignment_function) and hash_foo_type is a function that properly hashes FooType objects. You can also specify to Streamlit that objects of type Bio.pairwise2.alignment_function should not be hashed via the following:

@st.cache(hash_funcs={Bio.pairwise2.alignment_function: lambda _: None})def my_cached_func(a, b):…

We also provide some helpful caching debugging tips here. Please let me know if you have any questions.



1 Like