Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EinarMichaelsen committed Jun 11, 2024
0 parents commit a334514
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Streamlit Template from dev container",
"image": "ghcr.io/streamlit/basic-template:latest",
"customizations": {
"codespaces": {
"openFiles": [
"README.md",
"streamlit_app.py"
]
}
},
"postAttachCommand": {
"server": "streamlit run streamlit_app.py --server.enableCORS false --server.enableXsrfProtection false"
},
"portsAttributes": {
"8501": {
"label": "Application",
"onAutoForward": "openPreview"
}
},
"forwardPorts": [
8501
]
}
14 changes: 14 additions & 0 deletions .github/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Streamlit Template image build and push",
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'"
}
35 changes: 35 additions & 0 deletions .github/workflows/devcontainer-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Dev Container Build and Push Image

on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*.*.*"
pull_requests:
branches:
- "main"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v1
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
-
name: Pre-build dev container image
uses: devcontainers/ci@v0.2
with:
subFolder: .github
imageName: ghcr.io/${{ github.repository }}
cacheFrom: ghcr.io/${{ github.repository }}
push: always
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
altair
pandas
streamlit
40 changes: 40 additions & 0 deletions streamlit_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st

"""
# Welcome to Streamlit!
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
In the meantime, below is an example of what you can do with just a few lines of code:
"""

num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
num_turns = st.slider("Number of turns in spiral", 1, 300, 31)

indices = np.linspace(0, 1, num_points)
theta = 2 * np.pi * num_turns * indices
radius = indices

x = radius * np.cos(theta)
y = radius * np.sin(theta)

df = pd.DataFrame({
"x": x,
"y": y,
"idx": indices,
"rand": np.random.randn(num_points),
})

st.altair_chart(alt.Chart(df, height=700, width=700)
.mark_point(filled=True)
.encode(
x=alt.X("x", axis=None),
y=alt.Y("y", axis=None),
color=alt.Color("idx", legend=None, scale=alt.Scale()),
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
))

0 comments on commit a334514

Please sign in to comment.