-
Notifications
You must be signed in to change notification settings - Fork 4k
Extend st.navigation functionality to support various page input types #10358
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
610b6f0 to
450e343
Compare
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.
Hey @ashm-dev Thanks for the PR. Let me double check with @jrieke on whether we want to support direct strings here. I see how this can be simpler, but I also see this as obfuscating the API at the possibilities.
EDIT: Ah I see @jrieke wrote the issue, so I bet he agrees. I'll double check and give this a review.
|
This is awesome, thanks so much @ashm-dev! I actually started a similar PR a while ago (#10074) but didn't get around to finish it up, so happy to let you take it across the finish line ;) Only had a brief look at the PR but my 2 cts:
@kmcgrady when this is merged, you can also close my PR. |
|
Got it, thank you for such feedback! Then I just add the ability to work with |
8138940 to
3eadc2a
Compare
|
I can change the docstrings in a followup PR since I'll need to change a bit. Although I'm already planning on implementing support for Notes and Raises, we don't use those yet so I'll reformat that information. (Otherwise, it can have unintended consequences for the docstring parser or docs site.) I'm planning on comprehensively documenting raised exceptions, but since no other public command has this yet, I'm inclined to leave it out until I take a pass at getting some basic coverage across the board for consistency. The examples section needs to keep its embedded apps and header labels, so I'll need to rework the examples and make sure the apps are consistent. Since that will take me a little time, I'll just do a followup to make it easy. 😃 |
|
@sfc-gh-dmatthews Ok got it, should I fix it in the current version, or is this PR already accepted, and you will update it yourself in the next one? |
3eadc2a to
e2b2781
Compare
|
@ashm-dev I can update it in the next PR. |
e2b2781 to
065898a
Compare
|
When will my PR be merged? |
|
Hey @ashm-dev I will review this today and hopefully it will be close. I can expect it to be merged this week. Our cutoff is set for Wednesday Feb 26th in the evening (Pacific Time), so we have plenty of time :-) |
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.
Everything looks great. Just some small comments (and making sure the checks all pass), and we can get this merged.
lib/streamlit/commands/navigation.py
Outdated
|
|
||
| if callable(page_input): | ||
| # Convert function to StreamlitPage | ||
| return Page(page_input) |
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.
For these, we want to use StreamlitPage, not Page. Page is annotated to assume it's an st call where StreamlitPage is the underlying function.
lib/streamlit/commands/navigation.py
Outdated
|
|
||
| raise StreamlitAPIException( | ||
| f"Invalid page type: {type(page_input)}. Must be either a string path, " | ||
| "a callable function, or a StreamlitPage object." |
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.
Probably should call this st.Page object since this is what users would be seeing.
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.
I call the object by its name in docs. st.Page isn't a class; it's a command to create an instance of a class. So st.Page is a command you call; StreamlitPage is the object you get from it.
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.
I followed the same logic, but once they said update, I redid it)
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.
I'll defer to Debbie here since she's our docs expert. If StreamlitPage makes the most sense, we can leave it as is (and sorry for the thrash)
|
Looking at the tests failing tests. I think you need to:
|
|
@kmcgrady Yes, there was a minor error in types and formatting, I fixed it, now I hope everything goes as it should) |
package-lock.json
Outdated
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.
Looks like this was created by mistake and committed. Should remove that
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.
Removed
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.
Homestretch. Looks like there were some files erroneously added. Can you remove them? I think the only thing is to remove references to Page in favor of StreamlitPage
|
Thanks @ashm-dev ! |
|
Awesome, thanks for adding this @ashm-dev! ❤️ |
Describe your changes
Added
convert_to_streamlit_pagefor converting various input types to StreamlitPageChanged
Documentation
GitHub Issue Link (if applicable)
Closes #10069
Testing Plan
The necessary tests have already been added
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.