window exec work with pyinstaller issue #180#183
Conversation
WalkthroughThis pull request introduces new asynchronous event loop management and settings handling in the application. An Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant EventLoop
participant Loader
participant Session
User->>App: Launch Application
App->>EventLoop: ensure_event_loop()
EventLoop-->>App: Return event loop (new or existing)
App->>Loader: load_settings()
Loader-->>App: Return settings or defaults with error (if file missing)
App->>Session: Update session state (initialize current_page)
App->>User: Render sidebar with navigation buttons
User->>App: Select a page
App->>User: Display selected page content
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
run_app_temp.spec (1)
11-18: Consider using relative paths instead of environment-specific pathsThe current paths are tied to a specific virtual environment location (
./myenv/), which might cause issues when building on different machines or CI/CD environments.Consider using a more environment-agnostic approach:
- datas += [ - ("./myenv/Lib/site-packages/altair/vegalite/v5/schema/vega-lite-schema.json", "./altair/vegalite/v5/schema/"), - ("./myenv/Lib/site-packages/streamlit/static", "./streamlit/static"), - ("./myenv/Lib/site-packages/streamlit/runtime", "./streamlit/runtime"), - ("./myenv/Lib/site-packages/pyopenms", "./pyopenms/"), - ("./myenv/Lib/site-packages/captcha", "./captcha/"), - ("./myenv/Lib/site-packages/pyarrow", "./pyarrow/"), - ] + import site + site_packages = site.getsitepackages()[0] + datas += [ + (f"{site_packages}/altair/vegalite/v5/schema/vega-lite-schema.json", "./altair/vegalite/v5/schema/"), + (f"{site_packages}/streamlit/static", "./streamlit/static"), + (f"{site_packages}/streamlit/runtime", "./streamlit/runtime"), + (f"{site_packages}/pyopenms", "./pyopenms/"), + (f"{site_packages}/captcha", "./captcha/"), + (f"{site_packages}/pyarrow", "./pyarrow/"), + ]🧰 Tools
🪛 RuboCop (1.73)
[fatal] 12-12: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
[fatal] 13-13: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
[fatal] 14-14: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
[fatal] 15-15: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
[fatal] 16-16: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
[fatal] 17-17: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
app.py (1)
15-25: Good error handling in settings loadingThe
load_settingsfunction handles the case where settings.json is missing gracefully, providing default values and informing the user. This is a robust approach to configuration management.However, consider adding error handling for JSON parsing issues:
def load_settings(): settings_path = Path(__file__).parent / "settings.json" if not settings_path.exists(): st.error("⚠️ Error: 'settings.json' is missing! Using default settings.") return { "app-name": "Default App", "version": "1.0.0", "analytics": {"google-analytics": {"enabled": False, "tag": ""}}, } - with open(settings_path, "r") as f: - return json.load(f) + try: + with open(settings_path, "r") as f: + return json.load(f) + except json.JSONDecodeError: + st.error("⚠️ Error: 'settings.json' contains invalid JSON! Using default settings.") + return { + "app-name": "Default App", + "version": "1.0.0", + "analytics": {"google-analytics": {"enabled": False, "tag": ""}}, + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app.py(1 hunks)run_app_temp.spec(1 hunks)
🧰 Additional context used
🪛 RuboCop (1.73)
run_app_temp.spec
[fatal] 9-9: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 12-12: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 13-13: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 14-14: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 15-15: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 16-16: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
[fatal] 17-17: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
(Lint/Syntax)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: build-simple-app
- GitHub Check: build-full-app
- GitHub Check: build-openms
🔇 Additional comments (10)
run_app_temp.spec (3)
2-2: Good addition of PyInstaller utility hooksAdding these utility functions is an excellent approach for automatically collecting submodules and data files, which helps solve dependency resolution issues with PyInstaller.
7-9: Comprehensive hidden imports and data collectionThis is a good solution to fix the PyInstaller packaging issue. Collecting submodules automatically and explicitly adding "pyexpat" addresses common PyInstaller bundling problems with these libraries. Including settings.json in the data files ensures it's properly packaged with the application.
🧰 Tools
🪛 RuboCop (1.73)
[fatal] 9-9: unexpected token tCOMMA
(Using Ruby 2.7 parser; configure usingTargetRubyVersionparameter, underAllCops)(Lint/Syntax)
22-25: Good configuration of Analysis parametersSetting
pathex=['.']is a good practice to ensure the project directory is in the Python path. Using the previously defineddatasandhiddenimportsvariables improves code organization and maintainability.app.py (7)
1-2: Appropriate import additionsAdding
jsonandasyncioimports is necessary for the new functionality being implemented.
6-13: Good implementation of event loop managementThe
ensure_event_loopfunction correctly handles event loop creation when needed, which is important for asynchronous operations in a Streamlit application. This helps prevent "no running event loop" errors.
28-30: Good initialization of session state variablesProperly initializing session state variables ensures consistent application state. Adding
current_pagetracking is a good enhancement for managing navigation.
32-54: Improved navigation structure with tuplesThe change from
st.Pageobjects to tuples simplifies the page definitions while maintaining all necessary information. This approach is more maintainable and readable.
56-67: Enhanced sidebar navigation with expandable categoriesThe new navigation system using expandable categories and buttons is a significant improvement for user experience. The code correctly tracks the selected page in session state for persistence.
68-70: Page loading feedback is helpfulProviding feedback when loading a page improves user experience by indicating that an action is being performed.
71-72: Good encapsulation with main functionMoving the application logic into a dedicated
main()function is a good practice for better code organization and potential reusability.
|
@Srajald can you please build via https://github.com/OpenMS/streamlit-template/blob/main/.github/workflows/build-windows-executable-app-with-pyinstaller.yaml (please try latest streamlit version and then test via install the executable and launched the app) try out to build in PR with |
|
@Arslan-Siraj |
Summary by CodeRabbit
New Features
Chores