Skip to content

Conversation

@AnOctopus
Copy link
Contributor

We only want to reset the callstack's local data after we are done adding the widget/media element to the message list for each cached function we are running in. Moving the creation of the message data class out of the loop, and saving it to each of the lists, accomplishes this with the bonus of saving some memory use.

📚 Context

  • Bugfix
  • Feature
  • Refactoring
  • Other, please describe:

🧠 Description of Changes

  • Hoist element message data creation out of loop in save_element_message

    • This is a breaking API change
    • This is a visible (user-facing) change

🧪 Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

🌐 References

Does this depend on other work, documents, or tickets?

We only want to reset the callstack's local data after we are done
adding the widget/media element to the message list for each cached
function we are running in. Moving the creation of the message data
class out of the loop, and saving it to each of the lists, accomplishes
this with the bonus of saving some memory use.
@AnOctopus AnOctopus requested a review from kajarenc November 18, 2022 20:17
@AnOctopus AnOctopus marked this pull request as draft November 18, 2022 20:36
We can't just early return because we need to do some cleanup.

Normally it shouldn't be possible to hit this code with values that
cause problems, but it can happen in tests that fiddle with internals by
patching.
@AnOctopus AnOctopus marked this pull request as ready for review November 18, 2022 22:05
@kajarenc
Copy link
Collaborator

LGTM 👍
I don't fully understand the machinery that's going on, but it looks good.
In particular, the movingElementMsgData creation. out of the loop is a good idea!

@AnOctopus AnOctopus merged commit 2936836 into streamlit:develop Nov 22, 2022
@AnOctopus AnOctopus deleted the fix/5677-nested-widget-replay branch November 22, 2022 21:37
tconkling added a commit to tconkling/streamlit that referenced this pull request Nov 22, 2022
* develop:
  `deprecation_util.py` (formerly `beta_util.py`) (streamlit#5754)
  Hoist element message data creation out of loop (streamlit#5734)
  Fail tests when all snapshots are not committed (streamlit#5729)
  Wrap type in quotes to support lower versions of protobuf (streamlit#5746)
  Fix py_snowflake for Nightly, Release Candidate & Release (streamlit#5747)
  Add GitHub Actions configuration to Dependabot (streamlit#5722)
  Fix snowpark integration test workflow (streamlit#5736)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

experimental_allow_widgets=True doesn't work in nested @st.experimental_singleton

2 participants