Test of Deepnote --> Github --> Streamlit
- Get pip upgraded in Deepnote everytime you run it
- Click on Python version dropdown on left side
- Choose link to Initiliazation notebook on right side
- Make a new line under line 2 with this command:
pip install --upgrade pip
- That should've crteated a
requirements.txt
file- Delete everything in it and replace it with:
streamlit==1.34.0 Pillow==10.3.0
- Delete everything in it and replace it with:
- In new Deepnote, make
MyProject/Streamlit
folder ->data
andassets
folders, add data/images - Make simple 3 cell analysis notebook
import pandas as pd import altair as alt
df_iris = pd.read_csv("MyProject/Streamlit/data/iris.csv") df_iris
alt.Chart(df_iris).mark_point().encode( x='petalLength', y='petalWidth', color='variety' )
- Make Run_streamlit notebook
from IPython.core.display import HTML import os
display(HTML(f'<h2><a href="https://{os.environ["DEEPNOTE_PROJECT_ID"]}.deepnoteproject.com" target="_blank">Click here</a> to open Streamlit</h2>')) print(f"https://" + os.environ["DEEPNOTE_PROJECT_ID"] + ".deepnoteproject.com")
!streamlit run ./MyProject/Streamlit/demo.py --server.port=8080 --browser.serverAddress='0.0.0.0'
- Set working directory to ProjectName
- Create /Streamlit/demo.py file
- Try running Run_Streamlit notebook
- Streamlit will run, but won't be visible in browser - 403 Forbidden
- Next to
Stop machine
button in bottom left, click the...
button - Slider for Allow Incoming Connections
- Try link again, it should show a page :)
- Downside, you need to keep restarting Streamlit run command to see new changes in Deepnote
- In your github, create a new repo - siads593_wi24_test
- Add a README.md file so there's at least one commit
- Add Deepnote Integration
- on left side,
Integrations
->+
-> scroll to Github - Choose newly created repo from drop down, at bottom probably
- Notice new
Github
next to new folder icon - Move Streamlit folder from under MyProject to under new folder (siads593_wi24_test)
- Delete ProjectName folder
- Fix path in Analysis and Run_Streamlit notebooks
- Check streamlit page still works
- Copy
requirements.txt
file to underneathStreamlit
folder
- on left side,
- Push notebooks to GitHub
- Click on Clock icon (version) in top right
Connect GitHub repository
button at very bottom- Choose the new repository you made
- Change path where notebooks will be exported to
/Deepnote/
- Add 'main' branch, then
Save
- Click
Commit & push
- Add title, this is only the notebooks, not the other of the files
- Push the other files to GitHub
- Open terminal
- cd siads593_wi24_test
- git status
- git remote -v
- git add Streamlit
- git pull origin main
- will fail git pull --rebase origin maingit add *- git commit -m "initial add of non-notebook files"
- git push origin main
--force - Now you should see your files in github :)
- Connect Github to Streamlit Community Cloud servers
- Sign in with github account
- New App
- Find repo in dropdown
- Point to
demo.py
file - it's smart - Add optional, pretty subdomain --> Deploy!
- Profit!