Skip to content

Refactor: pems_streamlit package #184

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

Merged
merged 9 commits into from
Jul 24, 2025
Merged

Refactor: pems_streamlit package #184

merged 9 commits into from
Jul 24, 2025

Conversation

thekaveman
Copy link
Member

@thekaveman thekaveman commented Jul 18, 2025

Closes #178

What this PR does

Follows the same general approach and outline from #181

streamlit_app becomes pems_streamlit

Rename the project directory following the new naming convention. This is now a true Python package with its own pyproject.toml listing dependencies and other metadata. The code is reorganized into the src structure similar to pems_web in #181.

Docker build process

Updates the Docker build into two stages, where the first builds a wheel for pems_streamlit and the second configures the runtime environment and installs the wheel.

Devcontainer

Update the package installation to ensure each is installed in editable mode. Instead of using the root level pyproject.toml, install them explicitly in the devcontainer Docker build.

Tests

Ensures coverage is reported for the new pems_streamlit package.

@thekaveman thekaveman self-assigned this Jul 18, 2025
@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch 3 times, most recently from 39e2055 to cbc737f Compare July 19, 2025 00:15
Copy link

github-actions bot commented Jul 19, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pems_streamlit/src/pems_streamlit
  main.py
  utils.py
Project Total  

This report was generated by python-coverage-comment-action

@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch from cbc737f to 1c0dfec Compare July 21, 2025 15:58
@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch from 1c0dfec to e259419 Compare July 21, 2025 18:53
Base automatically changed from refactor/pems-web to main July 22, 2025 13:40
@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch from e259419 to 3ed130e Compare July 22, 2025 13:41
@thekaveman thekaveman marked this pull request as ready for review July 22, 2025 13:44
@thekaveman thekaveman requested a review from a team as a code owner July 22, 2025 13:44
Copy link
Member

@lalver1 lalver1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! And thanks for going over it with me. I just have a minor request, in the comments, related to the default Streamlit app.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably leave this file blank since we now have a real Streamlit application in the repo. Also, with the new pems_streamlit package, the code in this file is getting ran whenever the package is imported the first time and we probably don't want that to happen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't need a default app page anymore, we can remove _default_app_page(), creating the default app page, and inserting the default app page in this file.

@thekaveman
Copy link
Member Author

Thanks @lalver1! Addressed your suggestions in c1fc59a.

@thekaveman thekaveman requested a review from lalver1 July 22, 2025 22:33
@thekaveman thekaveman marked this pull request as draft July 23, 2025 16:23
@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch from 774bb4e to 8a3ce21 Compare July 23, 2025 16:49
@thekaveman
Copy link
Member Author

@lalver1 8a3ce21 should resolve the issue we were discussing with editable installs of the local packages.

7e174b4 was a necessary follow-up to ensure tests continue to run in CI.

@thekaveman thekaveman marked this pull request as ready for review July 23, 2025 16:54
Copy link
Member

@lalver1 lalver1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @thekaveman! The editable installs now work, so when I run the debugger I can see the changes I make to the templates in the source.

Just one thing, we removed the default Streamlit page but it looks like st.navigation doesn't like this, it seems to expect at least one page tagged as a default page:

Page not found

The page that you have requested does not seem to exist. Running the app's main page.

But, the comment below fixes it. I tried the change locally and I don't get the error shown above.

@@ -51,8 +47,6 @@ def _make_app_page(app_path: Path) -> StreamlitPage:


def discover_apps() -> list[StreamlitPage]:
default_app_page = _default_app_page()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have to add back in _default_app_page(), creating the default app page, and inserting the default app page to have at least one page tagged as default. But we still leave the __init__.py blank as we have it right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I should have checked. Fixed and rebased.

pip installing the root-level pyproject.toml with package dependencies
didn't install them in editable mode, meaning it was difficult to work
with the code in the devcontainer

instead explicitly pip install each package as editable in the Docker build
process
@thekaveman thekaveman force-pushed the refactor/pems-streamlit branch from 7e174b4 to 9be9a63 Compare July 23, 2025 22:56
@thekaveman thekaveman requested a review from lalver1 July 23, 2025 23:06
Copy link
Member

@lalver1 lalver1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🎉

@thekaveman thekaveman merged commit a1ed1d3 into main Jul 24, 2025
9 checks passed
@thekaveman thekaveman deleted the refactor/pems-streamlit branch July 24, 2025 14:59
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.

Rename streamlit_app to pems_streamlit
2 participants