Skip to content

Conversation

@sfc-gh-tteixeira
Copy link
Contributor

Describe your changes

Today, when st.navigation is present in an app, any code using ProcessPoolExecutor will throw an exception. Turns out this is because ProcessPoolExecutor spins up a separate pure-Python process, and there's a bug that causes st.navigation not to work in pure-Python mode (it requires a ScriptRunContext).

This wasn't caught before because our pure-Python tests (make bare-execution-tests) weren't actually running for scripts in subfolders of the main test folder.

...and when you run those previously-untested tests you discover st.page_link also doesn't work in pure-Python mode!

So this PR addresses all of the above:

  1. Makes st.navigation and st.page_link work in pure-Python mode -- and therefore also when running inside a ProcessPoolExecutor
  2. Makes bare-execution-tests test MPAv1 and MPAv2 code

GitHub Issue Link (if applicable)

n/a

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python): ❌
  • E2E Tests: ✅
  • Any manual testing needed? ❌

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@kmcgrady kmcgrady added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Jan 14, 2025
Copy link
Collaborator

@kmcgrady kmcgrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for catching this!

@sfc-gh-tteixeira sfc-gh-tteixeira merged commit cc8ccc3 into develop Jan 15, 2025
43 of 46 checks passed
@sfc-gh-tteixeira sfc-gh-tteixeira deleted the bare-mpas branch January 15, 2025 19:14
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
…lit#10163)

## Describe your changes

Today, when `st.navigation` is present in an app, any [code using
`ProcessPoolExecutor`](https://discuss.streamlit.io/t/make-apps-faster-by-moving-heavy-computation-to-a-separate-process/68541#method-2-use-a-processpoolexecutor-5)
will throw an exception. Turns out this is because `ProcessPoolExecutor`
spins up a separate pure-Python process, and there's a bug that causes
`st.navigation` not to work in pure-Python mode (it requires a
ScriptRunContext).

This wasn't caught before because our pure-Python tests (`make
bare-execution-tests`) weren't actually running for scripts in
_subfolders_ of the main test folder.

...and when you run those previously-untested tests you discover
`st.page_link` _also_ doesn't work in pure-Python mode!

So this PR addresses all of the above:
1. Makes `st.navigation` and `st.page_link` work in pure-Python mode --
and therefore also when running inside a `ProcessPoolExecutor`
2. Makes `bare-execution-tests` test MPAv1 and MPAv2 code

## GitHub Issue Link (if applicable)

n/a

## Testing Plan

- ~~Explanation of why no additional tests are needed~~
- Unit Tests (JS and/or Python): ❌ 
- E2E Tests: ✅ 
- Any manual testing needed? ❌ 

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants