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

Added script for turning any nada program and test into a streamlit app #36

Merged
merged 8 commits into from
Oct 10, 2024
Merged
31 changes: 25 additions & 6 deletions streamlit_demo_apps/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Deploying Streamlit Apps

To deploy Streamlit apps, they need to be written and committed to a public GitHub repository.
This guide will show you how to quickly spin up a Nillion Testnet connected, live Streamlit app from our template using the simple generate-streamlit-app script. Once your app is ready, you can easily deploy it by pushing it to a public GitHub repo. Just follow these steps to get started:
Copy link
Member

Choose a reason for hiding this comment

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

a Nillion Testnet connected, live Streamlit app f

this reads a bit odd - but might be me.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about "Follow the steps to deploy a live Streamlit app for your Nada program. The app will connect to the Nillion Testnet to store your Nada program, store secret inputs (or use computation time secrets), and run blind computation"


## How to add a new Streamlit App

### 0. Create a streamlit secrets file and add your nilchain private key within `.streamlit/secrets.toml`
### 0. Create a streamlit secrets file

Run this command to create a `.streamlit/secrets.toml` copied from the example.

```
cp .streamlit/secrets.toml.example .streamlit/secrets.toml
```

Add your Nilchain private key to the .streamlit/secrets.toml file. The private key must be linked to a funded Nillion Testnet address that was created using a Google account (not a mnemonic). This allows you to retrieve the private key from Keplr. If you don’t have a Testnet wallet yet, you can learn how to create one here: https://docs.nillion.com/testnet-guides

### 1. Run the script to generate a new streamlit app for your program

From the root folder of this repo, run the generate-streamlit-app script:
Expand All @@ -33,7 +37,7 @@ streamlit run streamlit_demo_apps/app_[your_program_name].py`

View the app in your browser to make sure everything works as expected.

### 4. Deploy your app
### 4. Commit your code to Github

Add and commit your new streamlit app code to your forked Github repo. (Code must be connected to a remote, open source GitHub repository to deploy a Streamlit app.)
Copy link
Contributor

@crypblizz8 crypblizz8 Sep 18, 2024

Choose a reason for hiding this comment

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

Forking repo was not mentioned in the main repo README / here. Should we explicitly mention this higher in case?

With my test - i cloned repo instead of forking it 😅


Expand All @@ -45,14 +49,29 @@ git push origin main

Once you've committed the open source code, you can click the "deploy" button within your local streamlit app. Sign in with Github and select the "Deploy Now" on Streamlit Community Cloud option to deploy the app for free.

#### Deploy an app settings
<img width="1000" alt="Streamlit Community Cloud" src="https://github.com/user-attachments/assets/74a70b4e-506c-41df-8d59-f949871c9a4e">


### 5. Deploy your app from Streamlit.io

When you click "Deploy Now" from your local app, you'll be taken to streamlit.io and asked to log in with Github to create a new Streamlit app. Set the main file path to your new app `streamlit_demo_apps/app_[your_program_name].py`

Set the main file path to your new app `streamlit_demo_apps/app_[your_program_name].py`
<img width="1000" alt="streamlit settings" src="https://github.com/user-attachments/assets/e3821aa4-44b6-4f16-8400-97e531dfef23">

#### Add your Nilchain Private Key using Advanced Settings > Secrets

Go to "Advanced settings" and in Secrets, copy in the contents of your .streamlit/secrets.toml file. At a minimum, make sure to add your secret private key:

```
nilchain_private_key = "YOUR_FUNDED_PRIVATE_KEY"
```

Save and click "Deploy" to deploy your testnet Streamlit app!
<img width="1000" alt="advanced settings" src="https://github.com/user-attachments/assets/6b48b225-60b7-41bd-8591-c04419131bf8">

Save and click "Deploy" to deploy your testnet-connected Streamlit app.

### 6. Access Your Live Streamlit App

Once deployed, you’ll get a live link to your Nillion Testnet Streamlit app!

Example live Streamlit App: https://stephs-nada-multiplication-app.streamlit.app/
Loading