STREAMLIT TRICKS - Web App RERUNS on every WIDGET CLICKS ? Here's WHAT-TO-DO |SessionState| PYTHON

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ม.ค. 2025

ความคิดเห็น • 109

  • @Avra_b
    @Avra_b  3 ปีที่แล้ว +2

    Blog Post and codes related to this video -
    medium.com/@avra42/streamlit-python-tips-how-to-avoid-your-app-from-rerunning-on-every-widget-click-cae99c5189eb

  • @pr0skis
    @pr0skis ปีที่แล้ว +11

    This was much more clear than the Streamlit examples. Great video!

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Hey thanks for such kind words . I’m happy to hear 🤗

  • @notmanas
    @notmanas ปีที่แล้ว +4

    I spent more than 16 hours with issues related to this. If only I had found you sooner!

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      That’s very kind of you :) I’m glad that you liked this video and it came useful. Stay in touch 🤗

  • @EvandroSegundo
    @EvandroSegundo 4 หลายเดือนก่อน +1

    Finally a useful example!!! It solved my problem. Thank you!!

    • @Avra_b
      @Avra_b  3 หลายเดือนก่อน

      Glad to hear !

  • @PepBytes
    @PepBytes ปีที่แล้ว +1

    Thank you so much, Avra, I found your Medium article after spending a few hours working on this, and it has worked perfectly!

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      This kind of comments are always very motivating for me to keep on creating more contents. I’m glad that it worked for you and also thanks for the affirmation that this old code is still 💪🏽 and working . Stay in touch 🤗

  • @jorge1869
    @jorge1869 3 ปีที่แล้ว +6

    Excellent, without a doubt, this channel is becoming the best niche to learn streamlit. You are doing a good job. Greetings

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว +1

      Hey Jorge , Thank you so much for this comment . Please keep on showering this love and support . And make sure to leave your feedbacks and suggestions. It will help me improve further. Stay in touch 🤗

  • @rbk.technology4747
    @rbk.technology4747 2 ปีที่แล้ว +4

    Superb man....
    Seriously was dying to solve this issue.
    I got to know.
    But after this 6 mins video its so crystal clear.
    First should have come to YT instead of Google and docs
    You made it simple and clean.
    Thanks a lot for all these videos.
    One day they will scale to 1 million views.
    As all of these are so valuable and lifesaver

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      These are such kind words from you . Thank you and this motivates me further . Stay in touch 🤗🎈

  • @MaximusGamingGG
    @MaximusGamingGG ปีที่แล้ว +1

    Thank you so much man !! Was really stuck with this and couldn't find a solution anywhere else. Great explanation !!

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Very happy to hear ! Stay in touch ☺️

    • @MaximusGamingGG
      @MaximusGamingGG ปีที่แล้ว

      Surely 😊

  • @subinnair3835
    @subinnair3835 ปีที่แล้ว +2

    Thaaanks a lot for uploading such amazing content on Streamlit sir !!

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Hey Subin ! This is so nice to hear , thanks 🤗

  • @theanxiousdude7515
    @theanxiousdude7515 2 ปีที่แล้ว +1

    Amazing! I searched for solution for hours. Thank god I came acorss your medium article and this video. Simple and easy way to deal with the session problem. Thank you so much dude

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว +1

      Hey thanks for feedback. I’m glad that it helped you . Stay in touch ❤️

    • @theanxiousdude7515
      @theanxiousdude7515 2 ปีที่แล้ว

      @@Avra_b I wil, thanks bro

  • @saxegothaea_conspicua
    @saxegothaea_conspicua ปีที่แล้ว +2

    Great video. Thank you very much. I was stuck figuring this out.

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      Very happy to hear mate !

  • @learnapplybuild
    @learnapplybuild 2 ปีที่แล้ว +2

    Bro I am surprised why only 190 likes on this video...... thanks a ton for this solution

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว +2

      Hey so glad to hear that you enjoyed the video :) stay in touch 🤗🎈

    • @learnapplybuild
      @learnapplybuild 2 ปีที่แล้ว

      @@Avra_b sure bro 🙌🏻😎 Followed you on medium😇

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      @@learnapplybuild Thank you, soon I'll put up with some new blog post out there, stay in touch, cheers :)

  • @danielblechinger6608
    @danielblechinger6608 ปีที่แล้ว +1

    Thank you for your help! Wouldn´t complete the job without your help !

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      So happy to hear Daniel ! Stay in touch 🤗

    • @danielblechinger6608
      @danielblechinger6608 ปีที่แล้ว

      @@Avra_b Of course :) will look your videos now more often :)

  • @tanmaypathak3774
    @tanmaypathak3774 13 วันที่ผ่านมา

    Great video, how do you have two download buttons that have different outputs? The apps keeps rerunning after clicking one of the download button

  • @PiyushSingh-ef1sh
    @PiyushSingh-ef1sh 7 หลายเดือนก่อน +1

    dont know how this works
    but it works !!!
    thanks!

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      That all matters ! Cheers

  • @yonnialvarez9388
    @yonnialvarez9388 2 ปีที่แล้ว +1

    this video was clreares than others , thanks sir, appreciate it,also i learned streamlit on your channel, thanks x2

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      So happy to hear this from you ! Do stay in touch :)

  • @joaoatos7938
    @joaoatos7938 ปีที่แล้ว +1

    Awesome video!

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Thanks ! I’m glad that you liked it 🤗

  • @arturgomes1654
    @arturgomes1654 ปีที่แล้ว +1

    Amazing video, it helped me so much! Thanks!

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      Very happy to hear ☺️

  • @kirupaagar6674
    @kirupaagar6674 11 หลายเดือนก่อน +1

    Bro you saved my 2 days of work

    • @Avra_b
      @Avra_b  10 หลายเดือนก่อน

      ❤️

  • @zbynekba
    @zbynekba ปีที่แล้ว +1

    Hi Avra, Thank you for sharing your knowledge with us.
    BTW, what application do you use for drawing your diagrams? It looks like hand-written, but I guess it is not.

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      Hi thanks 🙏🏽 usually I use exclidraw or tldraw online tools .

  • @SaravananB-d4n
    @SaravananB-d4n ปีที่แล้ว +1

    Very helpful video, thank you bro ❤️

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Very happy to hear ☺️

  • @chriskeo392
    @chriskeo392 ปีที่แล้ว +1

    How can u create a select all check box to select all check boxes?

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      Hi , there can be number of ways to implement such functionality. ATM - what comes to my mind is like - the select all check box , has an on click function - which swaps the value of other check boxes ( the other check boxes got it’s value stored in session state ) .
      In short - look for the implementation of session state and on click function .
      Hope this helps .

  • @swastisunder
    @swastisunder 21 วันที่ผ่านมา

    i want when i clicked a button my page have to rerun from start

  • @HarhanDerMann
    @HarhanDerMann 3 ปีที่แล้ว +2

    Hey, I'm having some issues initializing the session_state. Even though I initialise it the same way as you did, or as a classic dictionary it doesn't seem to recognize it and I get an error. Do you have any idea what the issue is?

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      Hey Thanks for your feedback. What's the error ? if you follow the exact lines, it shouldn't . Please check your Streamlit version. How about referring to the doc once , docs.streamlit.io/library/api-reference/session-state
      Do let me know, stay in touch :)

    • @HarhanDerMann
      @HarhanDerMann 3 ปีที่แล้ว +1

      @@Avra_b Yeah I followed the same lines as you did.
      The error was:
      AttributeError: st.session_state has no attribute "load_state". Did you forget to initialize it?
      I should have the latest streamlit version since I downloaded it this week, but just in case how would I check the exact version? And which version would be necessary?
      Anyways thanks for your quick reply!

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      @@HarhanDerMann So, yeah it's because of the initialisation. Please refer to 04:35 of the video. There I refer to the Initialization part . Apologies, I'll update Time-Stamp for quick scrolling.
      Otherwise, you can check the Blog Post as well - medium.com/@avra42/streamlit-python-tips-how-to-avoid-your-app-from-rerunning-on-every-widget-click-cae99c5189eb
      If the problem still persist let me know. Cheers.

    • @HarhanDerMann
      @HarhanDerMann 3 ปีที่แล้ว +1

      @@Avra_b I copied your exact code but it still won't initialize. I have no clue what's going wrong

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      @@HarhanDerMann Okay, let's try with Streamlit's documentation code. Does that work for you ? Can you please send me link to your GitHub repo otherwise.

  • @genesistorrico343
    @genesistorrico343 2 ปีที่แล้ว +1

    Thank you very much, your video helped me a lot. Excellent explanation thanks!

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว +1

      Thank you for your feedback! Very kind of you , this undoubtedly motivates me to create more content and share with you all . Cheers

  • @maivish100
    @maivish100 8 หลายเดือนก่อน

    How to make column header dynamic with colour coding, is it already inbuilt feature in ST.?

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Elaborate a bit more please

  • @bhanu.s
    @bhanu.s 6 หลายเดือนก่อน

    I have a table and for that table i have added filters with buttons.
    When the button is clicked the whole app is rerunning.
    I have tried session.state also. Please help me on this

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Streamlit now has now api to run part of a function. Alternatively, you can wrap up the table within a cache function

  • @hamzaahmad564
    @hamzaahmad564 2 ปีที่แล้ว +1

    Yoo,
    is there a way to programatically update the value of a widget? (for example update the value of a slider through the code)

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Apologies for my late reply . Yes it’s value , by assigning a value to the widgets , for instance incase of slider .

  • @minnie3569
    @minnie3569 2 หลายเดือนก่อน

    thank you so muchhhhh i love youuu it was so useful

    • @Avra_b
      @Avra_b  2 หลายเดือนก่อน

      🫶🏽

  • @t4n_shahin
    @t4n_shahin 3 หลายเดือนก่อน

    you are a life saver

    • @Avra_b
      @Avra_b  3 หลายเดือนก่อน +1

      Your comment is my positivity boost on a Sunday Morning , cheers !

  • @sal6436
    @sal6436 3 ปีที่แล้ว +1

    If we're want to run only part of code after clicking the widget , and that part of code uses the variables of other part of code that we don't want to rerun , then what should we do?

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      If I understood you correctly, wrapping those part of code within a Cache functions would do the trick. st.cache() or st.experimental_memo(). You can refer to the last part of my Blog Post where I mentioned about this - medium.com/@avra42/streamlit-python-tips-how-to-avoid-your-app-from-rerunning-on-every-widget-click-cae99c5189eb
      I hope this solves, otherwise apologies but please mention an use-case, which will help me to understand your question better. Stay In touch and let me know :)

  • @otherside_ofqila
    @otherside_ofqila 3 ปีที่แล้ว +1

    Very informative video 😁 I am currently working on with streamlit, and I can't wait to implement these infos.. Thanks 😁 I also would like to see if you can make buttons that after you click, it can call other python scripts from other page into the current page.. Thank you in advance 😁

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      Hey thank you for your feedback. I’m glad that you liked this video. Your suggestion seems interesting, can you please elaborate further with an use case may be ? Thanks . Let’s stay in touch and please always feel free to share your feedbacks :)

  • @AnkurSingh-kj9wu
    @AnkurSingh-kj9wu ปีที่แล้ว +1

    You are great! Thanks a lot! :-)

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Hey Ankur! You being too kind , thanks anyways 🤗

    • @AnkurSingh-kj9wu
      @AnkurSingh-kj9wu ปีที่แล้ว +1

      @@Avra_b Just because of you, The error I was trying since yesterday got solved in less than a minute. 😄

    • @Avra_b
      @Avra_b  ปีที่แล้ว +1

      Happy to hear 🤗💛

  • @parobe6167
    @parobe6167 9 หลายเดือนก่อน

    Hi! Amazing video, but for me it's not working. I've a multipage app and in one page I want to implement a neasted button. I have something like:
    if "Run PK Analysis" not in st.session_state:
    st.session_state["Run PK Analysis"] = False
    if st.button("Run PK Analysis", key="pk_button") or st.session_state['Run PK Analysis']:
    st.session_state['Run PK Analysis']=True
    with st.spinner("Building graphs..."):
    time.sleep(5)
    if 'df_result' in st.session_state:
    #code
    if st.button("PK interpretation", key="inter"):
    # Display PK interpretation content here
    st.write("PK interpretation content goes here."
    elif 'df_upload' in st.session_state:
    #code
    when I press second button ('pk interpretation') the page is refreshing...
    Could you help me?

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Hmm interesting. I’ve to give it a spin . Not sure atm

  • @beyblade600
    @beyblade600 2 ปีที่แล้ว +1

    Thanks for an excellent tutorial, however I am still struggling with how to store pyplots in session_state. As whenever i update any widget, my rendered image reloads again, even when its the same image. I have tried storing pyplot instance in sessions but its still not working, any idea how do I avoid that?

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Was your issue resolved ?

  • @nikhil141088
    @nikhil141088 2 ปีที่แล้ว +1

    great video. Kudos to you!

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Hey thanks Nikhil for such kind word 🤗

  • @bhaskarturkar2863
    @bhaskarturkar2863 ปีที่แล้ว +1

    Great video , Thanks

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      Happy to hear 🤗

  • @jyoti04411
    @jyoti04411 ปีที่แล้ว

    How is different than cache data features

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Which part ?

  • @dishydez
    @dishydez 2 ปีที่แล้ว +1

    As always great tutorial. Isbit possible to do the user authentication again but with session state included as well as st. Experimental params? Would be good to mesh these together. Thanks anyway!

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว +1

      Hi that’s indeed a great suggestion ! I’m planning to review few more Streamlit Components which covers user authentication. I’ll update you once I finish that . Stay in touch :)

  • @アルズぺイマサマン
    @アルズぺイマサマン 2 ปีที่แล้ว +1

    brilliant!

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Thank you 🤗

  • @kugann3421
    @kugann3421 2 ปีที่แล้ว +1

    Thank you

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Hey you are welcome 🤗

  • @whitename7764
    @whitename7764 ปีที่แล้ว +1

    Great!!!

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      ☺️

  • @123xxxify
    @123xxxify 2 ปีที่แล้ว +1

    Nice sir, from Doge Vietnam

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Glad to see you here . Stay in touch 🤗

  • @thghtfl
    @thghtfl 3 ปีที่แล้ว

    that actually does NOT stop streamlit from rerunning the app, you just don’t see that is happening due to small amount of initializing data

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      Hi @Igor , thanks for your feedback. I would like to understand more clearly this issue , can you please provide me with your use case ? As far as it goes, the video mainly indicates the workaround with the widgets active state. Data loading at every run can be ignored as well, for that wrapping within a function is necessary ( mentioned in the blog post )

  • @Kinematician30
    @Kinematician30 3 ปีที่แล้ว +1

    HEY! Avra can I get your Linkedin profile?

    • @Avra_b
      @Avra_b  3 ปีที่แล้ว

      You can find me here - www.linkedin.com/in/avratanu-biswas-708616b7

  • @kunalr_ai
    @kunalr_ai 7 หลายเดือนก่อน +1

    Watching today in 17 jun 2024 😂😂

    • @Avra_b
      @Avra_b  4 หลายเดือนก่อน

      Wdyt?

    • @kunalr_ai
      @kunalr_ai 4 หลายเดือนก่อน

      @@Avra_b what is the question?

  • @scankomp241
    @scankomp241 2 ปีที่แล้ว +1

    Что здесь происходит )

  • @photon2724
    @photon2724 ปีที่แล้ว +1

    Streamlit should be burned for this! like how is this ever a good feature?!

    • @Avra_b
      @Avra_b  ปีที่แล้ว

      It’s a trade I would say .
      We get the ease of development and prototyping quickly , trading with such inefficient state of widgets. There are frameworks nice niceGUI / Reflex / Solara - better in dealing with it

  • @isaquedavid4064
    @isaquedavid4064 2 ปีที่แล้ว +1

    • @Avra_b
      @Avra_b  2 ปีที่แล้ว

      Thank you David ! Stay in touch 🤗