MCPcopy Create free account
hub / github.com/streamlit/streamlit / _mpa_v1

Function _mpa_v1

lib/streamlit/runtime/scriptrunner/script_runner.py:132–171  ·  view source on GitHub ↗
(main_script_path: str)

Source from the content-addressed store, hash-verified

130# function will be called to run the script in lieu of the main script. This
131# function simulates the v1 setup using the modern v2 commands (st.navigation)
132def _mpa_v1(main_script_path: str) -> None:
133 from pathlib import Path
134
135 from streamlit.commands.navigation import PageType, _navigation
136 from streamlit.navigation.page import StreamlitPage
137
138 # Select the folder that should be used for the pages:
139 resolved_main_script_path: Final = Path(main_script_path).resolve()
140 pages_folder: Final = resolved_main_script_path.parent / "pages"
141
142 # Read out the my_pages folder and create a page for every script:
143 pages = sorted(
144 [
145 page
146 for page in pages_folder.glob("*.py")
147 if page.name.endswith(".py")
148 and not page.name.startswith(".")
149 and page.name != "__init__.py"
150 ],
151 key=page_sort_key,
152 )
153
154 # Use this script as the main page and
155 main_page = StreamlitPage(resolved_main_script_path, default=True)
156 all_pages = [main_page] + [
157 StreamlitPage(pages_folder / page.name) for page in pages
158 ]
159 # Initialize the navigation with all the pages:
160 position: Literal["sidebar", "hidden", "top"] = (
161 "hidden"
162 if config.get_option("client.showSidebarNavigation") is False
163 else "sidebar"
164 )
165 page = _navigation(
166 cast("list[PageType]", all_pages),
167 position=position,
168 expanded=False,
169 )
170
171 page.run()
172
173
174class ScriptRunner:

Callers 1

code_to_execMethod · 0.85

Calls 3

StreamlitPageClass · 0.90
_navigationFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…