question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cached function running too frequently with stringio objects

See original GitHub issue

Here is a bug noticed by a user on the forum. The code snippet below is reproducible. To see more here is the forum topic.

Quote by santosh_boina:

"But, when i use checkbox/selectbox/radio features to filter data to be shown as plots on tool, it reruns entire app.py script and starting from loading data again. Have I overlooked or missed something to include in my code to avoid this kind of problems.

My code is given here:

df_uploaded = st.sidebar.file_uploader(‘Choose txt file:’,type = [‘txt’,‘csv’]) @st.cache(hash_funcs={StringIO: StringIO.getvalue}) def load_data(file_uploaded): return (pd.read_table(file_uploaded,header=None,encoding=‘utf-8’)) if df_uploaded: temp = load_data(df_uploaded) select_cols = st.selectbox('Choose column for analysis', list(temp.columns)) if select_cols: ** code to plot the variable distribution/scatter plot"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tc87commented, Jun 29, 2020

Hey @will-holley,

This was first natively supported in 0.57.0. Here is the pull request if interested in taking a look.

0reactions
will-holleycommented, Jun 29, 2020

Thanks, @tc87.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is StringIO in python used for in reality? - Stack Overflow
It's used when you have some API that only takes files, but you need to use a string. For example, to compress a...
Read more >
functools — Higher-order functions and operations on callable ...
The cached_property decorator only runs on lookups and only when an attribute of the same name doesn't exist. When it does run, the...
Read more >
Performance — SQLAlchemy 1.4 Documentation
Object will not produce a cache key, Performance Implications - additional information regarding the warnings generated for elements that don't enable caching.
Read more >
StringIO Module in Python - Javatpoint
It is the StringIO module is an in-memory, file-like object. It can be used to input or output the majority of functions users...
Read more >
Python: Manage data as file object (StringIO) - LinkedIn
Introduction: In some cases, data reading and writing are not necessarily in files, but it needs to be read and written in memory....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found