Skip to content
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

[STREAMLIT] Demo interface for applications #2405

Open
4 of 6 tasks
blythed opened this issue Aug 21, 2024 · 1 comment · Fixed by #2591
Open
4 of 6 tasks

[STREAMLIT] Demo interface for applications #2405

blythed opened this issue Aug 21, 2024 · 1 comment · Fixed by #2591

Comments

@blythed
Copy link
Collaborator

blythed commented Aug 21, 2024

Users should be able to serve multiple demos for a range of applications in their deployment/ db. These demos should not
need to be prespecified at a set path, but should be "installable" in some sense.

Here is an example where we can toggle between multiple views in a single interface:

import streamlit as st

# Function for the first page
def page_one():
    st.title("Page One")
    st.write("Welcome to Page One!")
    st.write("Here is some content specific to the first page.")

# Function for the second page
def page_two():
    st.title("Page Two")
    st.write("Welcome to Page Two!")
    st.write("Here is some content specific to the second page.")

# Function for the third page
def page_three():
    st.title("Page Three")
    st.write("Welcome to Page Three!")
    st.write("Here is some content specific to the third page.")

# Main app
def main():
    st.sidebar.title("Navigation")
    page = st.sidebar.selectbox("Choose a page:", ["Page One", "Page Two", "Page Three"])
    
    # Display the selected page
    if page == "Page One":
        page_one()
    elif page == "Page Two":
        page_two()
    elif page == "Page Three":
        page_three()

if __name__ == "__main__":
    main()

In our implementation, the pages will come from the saved streamlit components/ applications. The functions will be saved as references and/ or artifacts in some way. This will mean that the main function needs to take db as a parameter.

@blythed
Copy link
Collaborator Author

blythed commented Nov 4, 2024

This code creates a demo per app, which can be used with <var:...> to go to Template.

class Streamlit(Component)
    type_id: t.ClassVar[str] = 'streamlit'
    kwargs: t.Dict = {}
    render_func = ...
    
    def render(self):
        # create app
        ...


if __name__ == '__main__':
    app = db.load('application', sys.arg[1])
    demo = next(c for c in app.components if c.type_id == 'streamlit')
    demo.render().run()

Now we a service on the distributed system, which should run all demos.

@blythed blythed linked a pull request Nov 4, 2024 that will close this issue
@blythed blythed reopened this Nov 4, 2024
@blythed blythed moved this from Done to To Do in superduper-open-source Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To Do
Development

Successfully merging a pull request may close this issue.

1 participant