-
Notifications
You must be signed in to change notification settings - Fork 4k
Add ConfigOption attribute "scriptable" w/ only some options scriptable=True #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ConfigOption attribute "scriptable" w/ only some options scriptable=True #702
Conversation
monchier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor comments. Looks good to me!
| visibility : {'visible', 'hidden', 'obfuscated'} | ||
| See __init__. | ||
| scriptable : bool | ||
| See __init__. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we say what scriptable means as part of the doc at this level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I see we document this below.
| """Test that scriptable options can be set from API.""" | ||
| # This is set in lib/tests/conftest.py to off | ||
| self.assertEqual("off", st.get_option("global.sharingMode")) | ||
| self.assertEqual(True, st.get_option("client.displayEnabled")) | ||
|
|
||
| st.set_option("global.sharingMode", "s3") | ||
| self.assertEqual("s3", st.get_option("global.sharingMode")) | ||
| # client.displayEnabled and client.caching can be set after run starts. | ||
| st.set_option("client.displayEnabled", False) | ||
| self.assertEqual(False, st.get_option("client.displayEnabled")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, this tests is about scriptable but requires that some specific options are "scriptable" and others are not. The test may break if we change these options or just we change just their name. In my mind, it would be nice to create a fake "scriptable" and a non "scriptable" option and testing the fakes, but not sure if it is easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point!
* develop: fixed misspell (streamlit#712) Add ConfigOption attribute "scriptable" w/ only some options scriptable=True (streamlit#702) Fixing Tornado on Windows + Python 3.8 (streamlit#682) Moving reportId and metadata from Element to ReportElement (streamlit#529) Fall back on webbrowser if xdg-open is not installed on Linux (streamlit#701) # Conflicts: # e2e/scripts/multiselect.py
* develop: (31 commits) fixed misspell (streamlit#712) Add ConfigOption attribute "scriptable" w/ only some options scriptable=True (streamlit#702) Fixing Tornado on Windows + Python 3.8 (streamlit#682) Moving reportId and metadata from Element to ReportElement (streamlit#529) Fall back on webbrowser if xdg-open is not installed on Linux (streamlit#701) Dockerfile: ensure we install the NODE_VERSION we reference elsewhere (streamlit#639) Datepicker pop-up aligned on left (streamlit#676) Fixing number input spin buttons for Firefox (streamlit#683) Fixing makeElementWithInfoText (streamlit#692) Fixing CTRL+ENTER on Windows (streamlit#699) Add option to use PollingFileWatcher, even if watchdog is available (streamlit#626) Break util.py into several util files (streamlit#703) Do not automatically create credential file when in headless mode (streamlit#467) (streamlit#603) make __future__ import be the first line (streamlit#687) Split text protos (streamlit#506) pandas.isna was introduced in version 0.21.0 (streamlit#679) Prefix get_report_ctx with underscore in __init__ and import it correctly in (streamlit#669) Fix single word in changelog (streamlit#672) Move some functions from util.py into type_util.py (streamlit#670) Release 0.50.2 (streamlit#666) ...
* develop: (38 commits) Add viz.js to the repo (streamlit#635) fixed misspell (streamlit#712) Add ConfigOption attribute "scriptable" w/ only some options scriptable=True (streamlit#702) Fixing Tornado on Windows + Python 3.8 (streamlit#682) Moving reportId and metadata from Element to ReportElement (streamlit#529) Fall back on webbrowser if xdg-open is not installed on Linux (streamlit#701) Dockerfile: ensure we install the NODE_VERSION we reference elsewhere (streamlit#639) Datepicker pop-up aligned on left (streamlit#676) Fixing number input spin buttons for Firefox (streamlit#683) Fixing makeElementWithInfoText (streamlit#692) Fixing CTRL+ENTER on Windows (streamlit#699) Add option to use PollingFileWatcher, even if watchdog is available (streamlit#626) Break util.py into several util files (streamlit#703) Do not automatically create credential file when in headless mode (streamlit#467) (streamlit#603) make __future__ import be the first line (streamlit#687) Split text protos (streamlit#506) pandas.isna was introduced in version 0.21.0 (streamlit#679) Prefix get_report_ctx with underscore in __init__ and import it correctly in (streamlit#669) Fix single word in changelog (streamlit#672) Move some functions from util.py into type_util.py (streamlit#670) ...
Issue: #163
Description:
This branch addresses a bug that highlighted a more general issue in the code, which is that most options created in config.py can't be productively set by the user in a script during
streamlit run script.py.Right now, since these options cannot reach the machinery of Streamlit that would change the behavior desired by the user, they are silently failing or causing unexpected problems when used inside of a user script.
The better behavior would be to raise an exception with an explanation for all options set in a script that are "unscriptable".
This PR adds a
scriptableattribute to the ConfigOption class, which allows each option to configure its own "scriptability" with the _create_option function.The
scriptableflag is then checked at runtime duringst.set_option, failing the script (if False) with StreamlitAPIException and a useful message about how to set the option properly.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.