Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The purpose of this project is to share knowledge on how Awesome [Streamlit](https://streamlit.io/) is and can become. [Pull requests](https://github.com/MarcSkovMadsen/awesome-streamlit/pulls) are very welcome!

Streamlit has just been [announced](https://towardsdatascience.com/coding-ml-tools-like-you-code-ml-models-ddba3357eace) (Oct 2019) but I see the potential of becoming the **Iphone of Data Science Apps**. And maybe it can even become the Iphone of Technical Writing, Code, Micro Apps and Python.
Streamlit has just been [announced](https://towardsdatascience.com/coding-ml-tools-like-you-code-ml-models-ddba3357eace) (Oct 2019) but I see the potential of it becoming the **iPhone of Data Science Apps**. And maybe it can even become the iPhone of Technical Writing, Code, Micro Apps and Python.

This project provides

Expand Down Expand Up @@ -90,7 +90,8 @@ A curated list of awesome streamlit resources. Inspired by [awesome-python](http
- [Sentiment Algorithm](https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/gallery/sentiment_analyzer/sentiment_analyzer.py) by [Paras Patidar](https://github.com/patidarparas13) (#App In Gallery, #Code, #Machine Learning)
- [SpacyIO](https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/gallery/spacyio/spacyio.py) by [Ines Montani](https://gist.github.com/ines) (#App In Gallery, #Code, #NLP)
- [Spreadsheet](https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/gallery/spreadsheet/spreadsheet.py) by [Marc Skov Madsen](https://datamodelsanalytics.com) (#App In Gallery, #Code)
- [Streamlit-components-demo Code](https://github.com/virusvn/streamlit-components-demo) (#Code)
- [Streamlit-components-demo Code](https://github.com/virusvn/streamlit-components-demo) (#Code)
- [Sudoku Solver](https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/gallery/sudoku_solver/sudoku_solver.py) by [Joshua Cook](https://joshuacook.netlify.app/) (#App, #App In Gallery, #Code)
- [Table Experiments](https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/gallery/table_experiments/app.py) by [Marc Skov Madsen](https://datamodelsanalytics.com) (#App In Gallery, #Code)
- [Uber Data Explorer App](https://dataexplorerlit.herokuapp.com/) (#Code)
- [Uber NYC Pickups](https://raw.githubusercontent.com/streamlit/demo-uber-nyc-pickups/master/app.py) by [Streamlit](https://streamlit.io/) (#App In Gallery, #Code)
Expand Down Expand Up @@ -126,14 +127,16 @@ A curated list of awesome streamlit resources. Inspired by [awesome-python](http

- [A step by step guide to running streamlit pytorch and bert on a cheap aws instance](https://fuzzyblog.io/blog/python/2019/10/17/a-step-by-step-guide-to-running-streamlit-pytorch-and-bert-on-a-cheap-aws-instance.html) (#Article, #Deployment, #Tutorial)
- [Building a ui for your latest ai](https://towardsdatascience.com/full-stack-ai-building-a-ui-for-your-latest-ai-project-in-no-time-at-all-7e5c8fd4eafd ) by [Luke Posey](https://github.com/Poseyy) (#Article, #Tutorial)
- [Building an Iris EDA App with Streamlit and Python](https://www.youtube.com/watch?v=L_mZcEMFUIc) by [Jesse E. Agbe (JCharis)](https://github.com/Jcharis) (#Tutorial, #Video)
- [Building an Iris EDA App with Streamlit and Python](https://www.youtube.com/watch?v=L_mZcEMFUIc) by [Jesse E. Agbe (JCharis)](https://github.com/Jcharis) (#Tutorial, #Video)
- [Creating A Stock Dashboard](https://www.linkedin.com/pulse/creating-stock-dashboard-curt-beck/?trackingId=AityTMjb3NukPM%2FZIrEoxA%3D%3D) by [Curt Beck](https://www.linkedin.com/pulse/creating-stock-dashboard-curt-beck/?trackingId=AityTMjb3NukPM%2FZIrEoxA%3D%3D) (#Article, #Tutorial)
- [Creating a Streamlit web app, building with Docker + GitHub Actions, and hosting on Heroku](https://joshuacook.netlify.app/post/streamlit-app-heroku/) by [Joshua Cook](https://joshuacook.netlify.app) (#Tutorial, #Article)
- [Full-Stack AI: Building a UI for Your Latest AI Project in No Time at All](https://towardsdatascience.com/full-stack-ai-building-a-ui-for-your-latest-ai-project-in-no-time-at-all-7e5c8fd4eafd) (#Article, #Image Recognition, #Tutorial)
- [How To Deploy Streamlit Apps (Using Heroku)](https://www.youtube.com/watch?v=skpiLtEN3yk&feature=youtu.be) (#Deployment, #Tutorial, #Video)
- [How to build your machine learning app in 3 simple steps](https://towardsdatascience.com/how-to-build-your-machine-learning-app-in-3-simple-steps-d56ed910355c) (#Article, #Deployment, #Tutorial)
- [How to create and deploy data exploration web app easily using python](https://medium.com/@ansjin/how-to-create-and-deploy-data-exploration-web-app-easily-using-python-a03c4b8a1f3e) (#Article, #Deployment, #Tutorial)
- [How to write web apps using simple python for data scientists](https://towardsdatascience.com/how-to-write-web-apps-using-simple-python-for-data-scientists-a227a1a01582) (#Article, #Tutorial)
- [Mining and Classifying Medical Text Documents](https://towardsdatascience.com/mining-and-classifying-medical-text-documents-1876462f73bc) by [Georgi Tancev](https://github.com/gtancev) (#Article, #Deployment, #NLP, #Tutorial)
- [Streamlit Python Tutorial (Crash Course)](https://www.youtube.com/watch?v=_9WiB2PDO7k) by [Jesse E. Agbe (JCharis)](https://github.com/Jcharis) (#Tutorial, #Video
- [Streamlit Python Tutorial (Crash Course)](https://www.youtube.com/watch?v=_9WiB2PDO7k) by [Jesse E. Agbe (JCharis)](https://github.com/Jcharis) (#Tutorial, #Video)

## Governance

Expand All @@ -147,7 +150,7 @@ You can learn more about me at [datamodelsanalytics.com](https://datamodelsanaly

I try my best to govern and maintain this project in the spirit of the [Zen of Python](https://www.python.org/dev/peps/pep-0020/).

But **i'm not an experienced open source maintainer** so helpfull suggestions are appreciated.
But **I'm not an experienced open source maintainer** so helpfull suggestions are appreciated.

Thanks

Expand Down Expand Up @@ -316,7 +319,7 @@ conda create -n awesome-streamlit python=3.7.4
and activate environment.

```bash
activate awesome-streamlit
conda activate awesome-streamlit
```

If you are on windows you need to install some things required by GeoPandas by following [these instructions](https://geoffboeing.com/2014/09/using-geopandas-windows/).
Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Main module for the streamlit app"""
import awesome_streamlit as ast
import streamlit as st

import awesome_streamlit as ast
import src.pages.about
import src.pages.gallery.index
import src.pages.home
Expand Down
3 changes: 1 addition & 2 deletions gallery/googleplaystore_analytics/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import streamlit as st

import dataset
import intro
import model
import references
import streamlit as st
import topic_modelling

PAGES = {
Expand Down
81 changes: 81 additions & 0 deletions gallery/sudoku_solver/pyomo_sudoku_solver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import re

import numpy as np
import pandas as pd
from pyomo import environ as pyo
from pyomo.dataportal import DataPortal
from pyomo.opt import SolverFactory

import pyutilib.subprocess.GlobalData

pyutilib.subprocess.GlobalData.DEFINE_SIGNAL_HANDLERS_DEFAULT = False


def solve_sudoku(known_cells):
known_cells.columns = ["i", "j", "k"]

# The grid indices and possible values.
N = np.arange(1, 9 + 1)

# Concrete model
model = pyo.ConcreteModel()

# Variable
model.X = pyo.Var(N, N, N, within=pyo.Binary)

# Constraints
model.row_constraint = pyo.ConstraintList()
model.col_constraint = pyo.ConstraintList()
model.block_constraint = pyo.ConstraintList()
model.allcells_constraint = pyo.ConstraintList()
model.knowncells_constraint = pyo.ConstraintList()

# Rows
for i in N:
for k in N:
model.row_constraint.add(sum(model.X[i, j, k] for j in N) == 1)

# Columns
for j in N:
for k in N:
model.col_constraint.add(sum(model.X[i, j, k] for i in N) == 1)

# Blocks
for i in np.arange(1, 9, 3):
for j in np.arange(1, 9, 3):
for k in N:
model.block_constraint.add(
sum(
model.X[p, q, k]
for p in np.arange(i, i + 3)
for q in np.arange(j, j + 3)
)
== 1
)

# All cells
for i in N:
for j in N:
model.allcells_constraint.add(sum(model.X[i, j, k] for k in N) == 1)

# Known cells
for i, j, k in zip(known_cells["i"], known_cells["j"], known_cells["k"]):
# if k != 0:
model.knowncells_constraint.add(model.X[i, j, k] == 1)

# Objective (none)
model.objective = pyo.Objective(expr=1)

# Solving
opt = SolverFactory("glpk")
solution = opt.solve(model)

res = np.zeros((9, 9))

for v in model.component_data_objects(pyo.Var, active=True):
val = v.value
if val > 0:
i, j, k = [int(x) for x in re.findall("[0-9]", v.name)]
res[i - 1, j - 1] = k

return res
5 changes: 5 additions & 0 deletions gallery/sudoku_solver/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numpy==1.19.4
pandas==1.1.5
pyomo==5.7.2
glpk
streamlit==0.73.1
67 changes: 67 additions & 0 deletions gallery/sudoku_solver/sudoku_solver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
## Sudoku Solver

A fast, interactive web application for solving Sudoku puzzles
using the optimization library Pyomo (https://www.pyomo.org/).

Author: [Joshua Cook](https://joshuacook.netlify.app))\n
Source: [Github](https://github.com/jhrcook/streamlit-sudoku)
"""
import streamlit as st

# Your imports goes below
import random
import re
from itertools import product

import streamlit as st
import pandas as pd
import numpy as np
from gallery.sudoku_solver.pyomo_sudoku_solver import solve_sudoku
from gallery.sudoku_solver.ui_auxiliary import empty_board_str, board_matrix_to_dataframe


def main():
st.title("Sudoku Solver")
st.markdown("A fast, interactive web application for solving Sudoku puzzles using the optimization library [Pyomo](https://www.pyomo.org/).")

# Your code goes below
random.seed(0)

input_data = st.text_area(
label="Enter the starting state of the board.", value=empty_board_str, height=400
)

rows = np.repeat(np.arange(1, 10), 9)
cols = np.tile(np.arange(1, 10), 9)
values = []

for line in input_data.split("\n"):
if not "-" in line:
vals = re.findall("[0-9]", line.rstrip())
values += [int(x) for x in vals]

if len(rows) == len(cols) == len(values):

known_cells = pd.DataFrame({"i": rows, "j": cols, "k": values})
board = known_cells.copy()

known_cells = known_cells[known_cells["k"] != 0]

board.k = ["" if x == 0 else str(x) for x in board.k]
board = board.pivot(index="i", columns="j", values="k")

if st.button("Solve!"):
st.markdown("**Solution**")
res = solve_sudoku(known_cells)
st.write(board_matrix_to_dataframe(res))
else:
st.markdown("**Board layout**")
st.write(board)


else:
st.write("Something is wrong with the layout of the board. Please try again.")


main()
21 changes: 21 additions & 0 deletions gallery/sudoku_solver/ui_auxiliary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pandas as pd
import numpy as np

empty_board_str = """-------------------------
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
-------------------------
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
-------------------------
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
| 0 0 0 | 0 0 0 | 0 0 0 |
-------------------------"""


def board_matrix_to_dataframe(ary):
df = pd.DataFrame(ary, columns=np.arange(1, 10))
return df
3 changes: 1 addition & 2 deletions gallery/test_runner_app/test_runner_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# pylint: disable=invalid-name
from typing import List

import streamlit as st

import awesome_streamlit as ast
import streamlit as st
from awesome_streamlit.database.apps_in_gallery import GITHUB_RAW_GALLERY_URL
from awesome_streamlit.testing.models import \
TesTItem # Special Capitalization is due to PyTest
Expand Down
1 change: 0 additions & 1 deletion package/awesome_streamlit/core/services/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import Optional

import streamlit as st

from awesome_streamlit.database.settings import GITHUB_RAW_URL


Expand Down
7 changes: 7 additions & 0 deletions package/awesome_streamlit/database/apps_in_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,12 @@
tags=[tags.CODE, tags.APP_IN_GALLERY],
author=authors.STEFANO_TABACCO,
),
Resource(
name="Sudoku Solver",
url=GITHUB_RAW_GALLERY_URL + "sudoku_solver/sudoku_solver.py",
is_awesome=True,
tags=[tags.CODE, tags.APP_IN_GALLERY, tags.APP],
author=authors.JOSHUA_COOK,
),
DEFAULT_APP_IN_GALLERY,
]
6 changes: 6 additions & 0 deletions package/awesome_streamlit/database/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
ESTEE_TEY = Author(name="Tey Siew Wen", url="https://github.com/lyqht")
COLLIN_PRATHER = Author(name="Collin Prather", url="https://github.com/collinprather")
STEFANO_TABACCO = Author(name="Stefano Tabacco", url="https://github.com/stabacco")
JOSHUA_COOK = Author(
name="Joshua Cook",
url="https://joshuacook.netlify.app",
# github_url="https://github.com/dchudz",
)

AUTHORS = [
ALEXANDRE_DOMINGUES,
Expand All @@ -66,4 +71,5 @@
DOUG_GUTHRIE,
ESTEE_TEY,
STEFANO_TABACCO,
JOSHUA_COOK
]
7 changes: 7 additions & 0 deletions package/awesome_streamlit/database/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@
tags=[tags.APP, tags.CODE],
author=authors.COLLIN_PRATHER,
),
Resource(
"Creating a Streamlit web app, building with Docker + GitHub Actions, and hosting on Heroku",
url="https://joshuacook.netlify.app/post/streamlit-app-heroku/",
is_awesome=True,
tags=[tags.TUTORIAL, tags.ARTICLE, tags.DEPLOYMENT, tags.GUIDE],
author=authors.JOSHUA_COOK,
),
]
+ STREAMLIT_EXAMPLE_APPS
+ STREAMLIT_EXAMPLE_APPS_FAILED_TEST
Expand Down
1 change: 0 additions & 1 deletion package/awesome_streamlit/testing/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Callable, List

import streamlit as st

from awesome_streamlit.testing import services
from awesome_streamlit.testing.models import TesTItem

Expand Down
1 change: 0 additions & 1 deletion package/awesome_streamlit/testing/services/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import List

import streamlit as st

from awesome_streamlit import database
from awesome_streamlit.shared.models import Resource
from awesome_streamlit.testing.models import TesTItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import pandas as pd
import streamlit as st

from awesome_streamlit.testing.models import TesTItem


Expand Down
2 changes: 1 addition & 1 deletion package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import pathlib

from setuptools import setup, find_packages
from setuptools import find_packages, setup

README_FILE_PATH = pathlib.Path(__file__).parent / "README.md"
with open(README_FILE_PATH) as f:
Expand Down
1 change: 0 additions & 1 deletion package/tests/core/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import urllib.request

import pytest

from awesome_streamlit.core import services


Expand Down
1 change: 0 additions & 1 deletion package/tests/shared/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Test of the models"""
import pytest

from awesome_streamlit.shared.models import Author, Resource, Tag


Expand Down
2 changes: 1 addition & 1 deletion package/tests/testing/test_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Here we test the models in the testing package"""
import pytest

# pylint: disable=redefined-outer-name
from awesome_streamlit.shared.models import Author, Resource, Tag
from awesome_streamlit.testing.models import TesTItem

from tests.testing.test_module_example_folder import test_module_example_file


Expand Down
1 change: 0 additions & 1 deletion package/tests/testing/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pathlib

import pytest

from awesome_streamlit.testing import utils

from . import test_module_example_folder
Expand Down
1 change: 1 addition & 0 deletions requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ docformatter==1.3.1
pycodestyle==2.6.0
yapf==0.30.0
pyformat==0.7.0
pyomo==5.7.2
Loading