Memoization Python Dash: TypeError: expected str, bytes or os.PathLike object, not Flask

364 Views Asked by At

I am developping a website with Python Dash and I am trying to implement caching, to speed up the performance of the website. I want to use memoization for this purpose, as suggested on the Dash website: https://dash.plotly.com/performance. On the website two different ways of memoization are shown; I want to memoize a callback using the FileSystemCache, so I need to combine both examples that are presented on the website.

I wrote the following lines of code to achieve this:

cache = Cache(app.server, config = {'CACHE_TYPE': 'FileSystemCache', 'CACHE_DIR': r"C:\Users\user_id\cache-directory", 'CACHE_DEFAULT_TIMEOUT': 300})

However, an error occurs when I try to implement the following lines of code:

TypeError: expected str, bytes or os.PathLike object, not Flask

How can I resolve this issue? It appears to be an error with the directory of the cache (I simply looked for the path towards 'cache-directory' on my computer and copied it). Yet at the same time I do not see a difference in implementation compared to the Dash website.

Thank you very much for your help!

1

There are 1 best solutions below

0
On

EDIT:

Had the same problem (running version 1.9.0) (current: 1.10.1, problem gone)

Simple solution: get a newer version.

If you can't change your version: change CACHE_TYPE to "filesystem", it will also do the trick.