Skip to content

fix(dashboard): ensure repository root is in sys.path for app startup - #16

Merged
MichalRedm merged 1 commit into
mainfrom
fix/dashboard-import-path
Oct 3, 2026
Merged

MichalRedm merged 1 commit into
mainfrom
fix/dashboard-import-path

Conversation

@MichalRedm

Copy link
Copy Markdown
Collaborator

Summary

  • Ensures that the STRIDE repository root directory is present in sys.path upon dashboard/app.py execution.
  • Fixes ModuleNotFoundError: No module named 'dashboard' when launching the app via streamlit run .\dashboard\app.py.

Motivation

When invoking streamlit run .\dashboard\app.py, Streamlit's script runner bootstrap prepends the target script's parent directory (dashboard/) to sys.path[0]. Because modules across dashboard/ use package-level imports like from dashboard.components.sidebar import ..., Python fails to locate dashboard as a top-level package unless the project root is explicitly present on sys.path.

Key Changes

  • In dashboard/app.py:
    • Resolved _PROJECT_ROOT = str(Path(__file__).resolve().parent.parent).
    • Added safe insertion sys.path.insert(0, _PROJECT_ROOT) before loading dashboard subcomponents.

Verification

  • ruff check . passed with 0 errors
  • ruff format --check . passed cleanly (105 files already formatted)
  • python -m unittest discover tests passed with 22/22 tests passing and 0 failures
  • Verified running streamlit run .\dashboard\app.py resolves package imports without error

@MichalRedm
MichalRedm merged commit 3096ecf into main Oct 3, 2026
1 check passed
@MichalRedm
MichalRedm deleted the fix/dashboard-import-path branch October 3, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant