-
Notifications
You must be signed in to change notification settings - Fork 4k
Add support for config & secret files on main-script level #10173
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
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
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.
Pull Request Overview
Adds support for per-script .streamlit config and secret files by tracking the main script path and extending the file lookup and watcher logic.
- Pass the main script path into the config system and include script-level files in both loading and file watchers.
- Introduce
get_main_script_streamlit_file_pathto build paths under a script’s.streamlitfolder. - Replace the static
CONFIG_FILENAMESlist with a dynamicget_config_files()and update the secrets/files option to be dynamic and multi-valued.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/streamlit/web/bootstrap.py | Set config._main_script_path and use get_config_files() in installers |
| lib/streamlit/file_util.py | Add get_main_script_streamlit_file_path helper |
| lib/streamlit/config_option.py | Add explicit multiple parameter to ConfigOption |
| lib/streamlit/config.py | Introduce _main_script_path, get_config_files(), and refactor secrets.files |
Comments suppressed due to low confidence (3)
lib/streamlit/file_util.py:164
- This function uses the
osmodule but there’s no import shown; ensureimport osis present at the top to avoid a NameError.
Path(os.path.abspath(os.path.dirname(main_script_path)))
lib/streamlit/config_option.py:188
- Auto-inference of
multiplebased ondefault_valwas removed, so any list-typed options withoutmultiple=Truewill now be single-valued; audit existing list defaults to ensure they passmultiple=Truewhere needed.
self.multiple = multiple
lib/streamlit/config.py:1283
- There’s a stray triple-quote here outside of a docstring or comment block, which could lead to a syntax error; verify that the
_secrets_filesdocstring is properly closed.
"""
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.
Pull Request Overview
This PR adds support for loading configuration and secret TOML files relative to the main script, and it updates the file resolution order for config and secret files. Key changes include:
- Updating CLI execution paths and patch targets in tests to use the new bootstrap/run and check_credentials functions.
- Introducing helper functions (e.g. get_main_script_streamlit_file_path) and a module-level main script path to resolve file locations correctly.
- Changing ConfigOption’s handling of multiple values by requiring an explicit flag rather than inferring from the default value.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/tests/streamlit/web/cli_test.py | Updated patches to align tests with new bootstrap and check_credentials calls. |
| lib/tests/streamlit/config_test.py | Added explicit multiple=True flag in tests for config options. |
| lib/streamlit/web/cli.py | Refactored main_run and main_hello to centralize config loading in _main_run. |
| lib/streamlit/web/bootstrap.py | Replaced CONFIG_FILENAMES with a call to get_config_files and updated sys path logic. |
| lib/streamlit/file_util.py | Added a new helper to resolve .streamlit paths relative to the main script. |
| lib/streamlit/config_option.py | Modified multiple-values handling by using an explicit parameter. |
| lib/streamlit/config.py | Added _main_script_path, refactored secrets and config file loading logic. |
| e2e_playwright/config/* | Added end-to-end tests to ensure script-level config and secret file support. |
Describe your changes
Adds support for loading secret and config files relative to the main script.
E.g. if you run
streamlit run my_app/app.py, it will load config & secret toml files in the following order:~/.streamlit/config.toml./my_project/.streamlit/config.toml./my_project/my_app/.streamlit/config.tomlGitHub Issue Link (if applicable)
config.tomlfile relative to main app file before defaulting to working directory #8195Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.