Jon Solow commited on
Commit
7a18dc2
1 Parent(s): 7e57d6a

Copy setup from JonSolow/streamlit-template

Browse files
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3
+ {
4
+ "name": "Existing Docker Compose (Extend)",
5
+
6
+ // Update the 'dockerComposeFile' list if you have more compose files or use different names.
7
+ // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8
+ "dockerComposeFile": [
9
+ "../docker-compose.yml",
10
+ "docker-compose.yml"
11
+ ],
12
+
13
+ // The 'service' property is the name of the service for the container that VS Code should
14
+ // use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15
+ "service": "streamlit",
16
+
17
+ // The optional 'workspaceFolder' property is the path VS Code should open by default when
18
+ // connected. This is typically a file mount in .devcontainer/docker-compose.yml
19
+ "workspaceFolder": "/app",
20
+ "customizations": {
21
+ "vscode": {
22
+ "extensions": [
23
+ "ms-python.python"
24
+ ]
25
+ }
26
+ }
27
+
28
+ // Features to add to the dev container. More info: https://containers.dev/features.
29
+ // "features": {},
30
+
31
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
32
+ // "forwardPorts": [],
33
+
34
+ // Uncomment the next line if you want start specific services in your Docker Compose config.
35
+ // "runServices": [],
36
+
37
+ // Uncomment the next line if you want to keep your containers running after VS Code shuts down.
38
+ // "shutdownAction": "none",
39
+
40
+ // Uncomment the next line to run commands after the container is created.
41
+ // "postCreateCommand": "cat /etc/os-release",
42
+
43
+ // Configure tool-specific properties.
44
+ // "customizations": {},
45
+
46
+ // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
47
+ // "remoteUser": "devcontainer"
48
+ }
.devcontainer/docker-compose.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+ services:
3
+ # Update this to the name of the service you want to work with in your docker-compose.yml file
4
+ streamlit:
5
+ # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6
+ # folder. Note that the path of the Dockerfile and context is relative to the *primary*
7
+ # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8
+ # array). The sample below assumes your primary file is in the root of your project.
9
+ #
10
+ build:
11
+ dockerfile: ./Dockerfile
12
+ context: ./
13
+ target: development
14
+
15
+ volumes:
16
+ # Update this to wherever you want VS Code to mount the folder of your project
17
+ - .:/app:cached
18
+
19
+ # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
20
+ # cap_add:
21
+ # - SYS_PTRACE
22
+ # security_opt:
23
+ # - seccomp:unconfined
24
+
25
+ # Overrides default command so things don't shut down after the process ends.
26
+ command: ["/bin/sh -c \"while sleep 1000; do :; done\""]
27
+
.gitignore ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app/Dockerfile
2
+
3
+ FROM python:3.11-slim as base
4
+
5
+ WORKDIR /app
6
+
7
+ RUN apt-get update && apt-get install -y \
8
+ build-essential \
9
+ curl \
10
+ software-properties-common \
11
+ git \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ RUN pip3 install pip-tools
15
+ COPY ./pyproject.toml .
16
+
17
+ FROM base as pip-service
18
+
19
+ COPY ./requirements.txt .
20
+ RUN pip3 install -r requirements.txt
21
+
22
+ FROM pip-service as service-setup
23
+ EXPOSE 8501
24
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
25
+ ENTRYPOINT ["./start.sh"]
26
+
27
+ FROM pip-service as service
28
+ WORKDIR /app/src
29
+ COPY ./src .
30
+
31
+ FROM service-setup as development
32
+ WORKDIR /app
33
+ COPY ./dev-requirements.txt .
34
+ RUN pip3 install -r dev-requirements.txt
35
+
36
+ WORKDIR /app/src
README.md CHANGED
@@ -10,3 +10,48 @@ pinned: false
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+
14
+ # streamlit-template
15
+
16
+ Template Repo for Streamlit Application
17
+
18
+ This repo can be used as a starting point for developing your Streamlit App.
19
+
20
+ Here are some of the features of the template:
21
+
22
+ - VSCode .devcontainer for local development: [Documentation](https://code.visualstudio.com/docs/devcontainers/containers)
23
+ - docker-compose.yml
24
+ - Dockerfile
25
+ - Linting Configuration [TO-DO] (allows for clean code and quicker detection of possible bugs as one of the first steps in Shift-left testing)
26
+ - [Black](https://black.readthedocs.io/en/stable/index.html)
27
+ - [ruff](https://beta.ruff.rs/docs/)
28
+ - [mypy](https://mypy.readthedocs.io/en/stable/index.html)
29
+ - Unit Tests
30
+ - [pytest](https://docs.pytest.org/)
31
+
32
+ # Start Here to Develop
33
+
34
+ 1. Prerequisites
35
+
36
+ - Install [Visual Studio Code](https://code.visualstudio.com/)
37
+ - Install [Visual Studo Code Extension - Dev containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
38
+ - Install [Docker](https://www.docker.com/)
39
+
40
+ 2. Confirm Docker is installed by executing command `docker -v`
41
+ 3. Open VSCode to a New Window and open this repository's directory
42
+ 4. You may see a notification that the Folder containers a Dev Container configuration file. If so, click on "Reopen in Container"
43
+
44
+ - If you do not see this notification, press `F1` key and begin typing the following until you can see the option "Dev Containers: Rebuild and reopen in Container".
45
+ - This action will reopen the VSCode within a Docker container suitable to develop and locally run the application.
46
+
47
+ 5. The dev container will start up the Streamlit application.
48
+
49
+ - To access the application, navigate to http://localhost:8501
50
+ - The container forwards the port 8501 where the Streamlit application is hosted
51
+ - Any changes made to the code will be reflected in the Streamlit application when you refresh.
52
+
53
+ 6. Now inside the VSCode dev container, to run tests, execute `./tests/run_tests.sh`
54
+
55
+ - This script has an optional argument `-f` for "fix mode" which allows for configuration of black and ruff to automatically apply fixes.
56
+
57
+ 7. As functions are added to the application, unit tests can/should be added in `tests/unit`, with existing support utilizing the `pytest` library.
dev-requirements.txt ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # This file is autogenerated by pip-compile with Python 3.11
3
+ # by the following command:
4
+ #
5
+ # pip-compile --extra=dev --output-file=dev-requirements.txt pyproject.toml
6
+ #
7
+ altair==5.0.1
8
+ # via streamlit
9
+ attrs==23.1.0
10
+ # via
11
+ # jsonschema
12
+ # referencing
13
+ black==23.7.0
14
+ # via streamlit-template (pyproject.toml)
15
+ blinker==1.6.2
16
+ # via streamlit
17
+ cachetools==5.3.1
18
+ # via streamlit
19
+ certifi==2023.7.22
20
+ # via requests
21
+ charset-normalizer==3.2.0
22
+ # via requests
23
+ click==8.1.6
24
+ # via
25
+ # black
26
+ # streamlit
27
+ gitdb==4.0.10
28
+ # via gitpython
29
+ gitpython==3.1.32
30
+ # via streamlit
31
+ idna==3.4
32
+ # via requests
33
+ importlib-metadata==6.8.0
34
+ # via streamlit
35
+ iniconfig==2.0.0
36
+ # via pytest
37
+ jinja2==3.1.2
38
+ # via
39
+ # altair
40
+ # pydeck
41
+ jsonschema==4.19.0
42
+ # via altair
43
+ jsonschema-specifications==2023.7.1
44
+ # via jsonschema
45
+ markdown-it-py==3.0.0
46
+ # via rich
47
+ markupsafe==2.1.3
48
+ # via jinja2
49
+ mdurl==0.1.2
50
+ # via markdown-it-py
51
+ mypy==1.5.1
52
+ # via streamlit-template (pyproject.toml)
53
+ mypy-extensions==1.0.0
54
+ # via
55
+ # black
56
+ # mypy
57
+ numpy==1.25.2
58
+ # via
59
+ # altair
60
+ # pandas
61
+ # pandas-stubs
62
+ # pyarrow
63
+ # pydeck
64
+ # streamlit
65
+ # streamlit-template (pyproject.toml)
66
+ packaging==23.1
67
+ # via
68
+ # black
69
+ # pytest
70
+ # streamlit
71
+ pandas==2.0.3
72
+ # via
73
+ # altair
74
+ # streamlit
75
+ # streamlit-template (pyproject.toml)
76
+ pandas-stubs==2.0.3.230814
77
+ # via streamlit-template (pyproject.toml)
78
+ pathspec==0.11.2
79
+ # via black
80
+ pillow==9.5.0
81
+ # via streamlit
82
+ platformdirs==3.10.0
83
+ # via black
84
+ pluggy==1.2.0
85
+ # via pytest
86
+ protobuf==4.24.0
87
+ # via streamlit
88
+ pyarrow==12.0.1
89
+ # via streamlit
90
+ pydeck==0.8.0
91
+ # via streamlit
92
+ pygments==2.16.1
93
+ # via rich
94
+ pympler==1.0.1
95
+ # via streamlit
96
+ pytest==7.4.0
97
+ # via streamlit-template (pyproject.toml)
98
+ python-dateutil==2.8.2
99
+ # via
100
+ # pandas
101
+ # streamlit
102
+ pytz==2023.3
103
+ # via pandas
104
+ pytz-deprecation-shim==0.1.0.post0
105
+ # via tzlocal
106
+ referencing==0.30.2
107
+ # via
108
+ # jsonschema
109
+ # jsonschema-specifications
110
+ requests==2.31.0
111
+ # via streamlit
112
+ rich==13.5.2
113
+ # via streamlit
114
+ rpds-py==0.9.2
115
+ # via
116
+ # jsonschema
117
+ # referencing
118
+ ruff==0.0.284
119
+ # via streamlit-template (pyproject.toml)
120
+ six==1.16.0
121
+ # via python-dateutil
122
+ smmap==5.0.0
123
+ # via gitdb
124
+ streamlit==1.25.0
125
+ # via streamlit-template (pyproject.toml)
126
+ tenacity==8.2.3
127
+ # via streamlit
128
+ toml==0.10.2
129
+ # via streamlit
130
+ toolz==0.12.0
131
+ # via altair
132
+ tornado==6.3.3
133
+ # via streamlit
134
+ types-pytz==2023.3.0.1
135
+ # via pandas-stubs
136
+ typing-extensions==4.7.1
137
+ # via
138
+ # mypy
139
+ # streamlit
140
+ tzdata==2023.3
141
+ # via
142
+ # pandas
143
+ # pytz-deprecation-shim
144
+ tzlocal==4.3.1
145
+ # via streamlit
146
+ urllib3==2.0.4
147
+ # via requests
148
+ validators==0.21.2
149
+ # via streamlit
150
+ watchdog==3.0.0
151
+ # via streamlit
152
+ zipp==3.16.2
153
+ # via importlib-metadata
docker-compose.yml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ streamlit:
3
+ build:
4
+ dockerfile: ./Dockerfile
5
+ context: ./
6
+ target: service
7
+ ports:
8
+ - '8501:8501'
9
+ environment:
10
+ - USER_ID=1000
11
+ - GROUP_ID=1000
pyproject.toml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+
4
+ [project]
5
+ requires-python = ">=3.9"
6
+ version = "1"
7
+ name = "streamlit-template"
8
+ dependencies = [
9
+ "streamlit",
10
+ "numpy",
11
+ "pandas",
12
+ ]
13
+
14
+ [project.optional-dependencies]
15
+ dev = [
16
+ "black",
17
+ "ruff",
18
+ "mypy",
19
+ "pytest",
20
+ "pandas-stubs",
21
+ ]
22
+
23
+ [tool.black]
24
+ line-length = 120
25
+ target-version = ["py311"]
26
+
27
+ [tool.ruff]
28
+ line-length = 120
29
+ src = ["src"]
30
+
31
+ [tool.mypy]
32
+ python_version = "3.11"
regenerate_requirements.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #!/bin/bash
3
+
4
+ set -ex
5
+
6
+ ADDITIONAL_ARGS=$@
7
+
8
+ pip-compile \
9
+ -o requirements.txt \
10
+ $ADDITIONAL_ARGS \
11
+ pyproject.toml
12
+
13
+ pip-compile \
14
+ --extra=dev \
15
+ -o dev-requirements.txt \
16
+ $ADDITIONAL_ARGS \
17
+ pyproject.toml
requirements.txt ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # This file is autogenerated by pip-compile with Python 3.11
3
+ # by the following command:
4
+ #
5
+ # pip-compile --output-file=requirements.txt pyproject.toml
6
+ #
7
+ altair==5.0.1
8
+ # via streamlit
9
+ attrs==23.1.0
10
+ # via
11
+ # jsonschema
12
+ # referencing
13
+ blinker==1.6.2
14
+ # via streamlit
15
+ cachetools==5.3.1
16
+ # via streamlit
17
+ certifi==2023.7.22
18
+ # via requests
19
+ charset-normalizer==3.2.0
20
+ # via requests
21
+ click==8.1.6
22
+ # via streamlit
23
+ gitdb==4.0.10
24
+ # via gitpython
25
+ gitpython==3.1.32
26
+ # via streamlit
27
+ idna==3.4
28
+ # via requests
29
+ importlib-metadata==6.8.0
30
+ # via streamlit
31
+ jinja2==3.1.2
32
+ # via
33
+ # altair
34
+ # pydeck
35
+ jsonschema==4.19.0
36
+ # via altair
37
+ jsonschema-specifications==2023.7.1
38
+ # via jsonschema
39
+ markdown-it-py==3.0.0
40
+ # via rich
41
+ markupsafe==2.1.3
42
+ # via jinja2
43
+ mdurl==0.1.2
44
+ # via markdown-it-py
45
+ numpy==1.25.2
46
+ # via
47
+ # altair
48
+ # pandas
49
+ # pyarrow
50
+ # pydeck
51
+ # streamlit
52
+ # streamlit-template (pyproject.toml)
53
+ packaging==23.1
54
+ # via streamlit
55
+ pandas==2.0.3
56
+ # via
57
+ # altair
58
+ # streamlit
59
+ # streamlit-template (pyproject.toml)
60
+ pillow==9.5.0
61
+ # via streamlit
62
+ protobuf==4.24.0
63
+ # via streamlit
64
+ pyarrow==12.0.1
65
+ # via streamlit
66
+ pydeck==0.8.0
67
+ # via streamlit
68
+ pygments==2.16.1
69
+ # via rich
70
+ pympler==1.0.1
71
+ # via streamlit
72
+ python-dateutil==2.8.2
73
+ # via
74
+ # pandas
75
+ # streamlit
76
+ pytz==2023.3
77
+ # via pandas
78
+ pytz-deprecation-shim==0.1.0.post0
79
+ # via tzlocal
80
+ referencing==0.30.2
81
+ # via
82
+ # jsonschema
83
+ # jsonschema-specifications
84
+ requests==2.31.0
85
+ # via streamlit
86
+ rich==13.5.2
87
+ # via streamlit
88
+ rpds-py==0.9.2
89
+ # via
90
+ # jsonschema
91
+ # referencing
92
+ six==1.16.0
93
+ # via python-dateutil
94
+ smmap==5.0.0
95
+ # via gitdb
96
+ streamlit==1.25.0
97
+ # via streamlit-template (pyproject.toml)
98
+ tenacity==8.2.3
99
+ # via streamlit
100
+ toml==0.10.2
101
+ # via streamlit
102
+ toolz==0.12.0
103
+ # via altair
104
+ tornado==6.3.3
105
+ # via streamlit
106
+ typing-extensions==4.7.1
107
+ # via streamlit
108
+ tzdata==2023.3
109
+ # via
110
+ # pandas
111
+ # pytz-deprecation-shim
112
+ tzlocal==4.3.1
113
+ # via streamlit
114
+ urllib3==2.0.4
115
+ # via requests
116
+ validators==0.21.2
117
+ # via streamlit
118
+ watchdog==3.0.0
119
+ # via streamlit
120
+ zipp==3.16.2
121
+ # via importlib-metadata
src/start.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ streamlit run streamlit_app.py --server.port=8501 --server.address=0.0.0.0
src/streamlit_app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ st.title("Uber pickups in NYC")
6
+
7
+ DATE_COLUMN = "date/time"
8
+ DATA_URL = "https://s3-us-west-2.amazonaws.com/" "streamlit-demo-data/uber-raw-data-sep14.csv.gz"
9
+
10
+
11
+ @st.cache_data
12
+ def load_data(nrows):
13
+ data = pd.read_csv(DATA_URL, nrows=nrows)
14
+ data.columns = data.columns.str.lower()
15
+ data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
16
+ return data
17
+
18
+
19
+ data_load_state = st.text("Loading data...")
20
+ data = load_data(10000)
21
+ data_load_state.text("Done! (using st.cache_data)")
22
+
23
+ if st.checkbox("Show raw data"):
24
+ st.subheader("Raw data")
25
+ st.write(data)
26
+
27
+ st.subheader("Number of pickups by hour")
28
+ hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0, 24))[0]
29
+ st.bar_chart(hist_values)
30
+
31
+ # Some number in the range 0-23
32
+ hour_to_filter = st.slider("hour", 0, 23, 17)
33
+ filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
34
+
35
+ st.subheader("Map of all pickups at %s:00" % hour_to_filter)
36
+ st.map(filtered_data)
tests/run_tests.sh ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Arguments for each test
4
+ BLACK_ARGS="--check"
5
+ RUFF_ARGS="check"
6
+ MYPY_ARGS=""
7
+ PYTEST_ARGS=""
8
+
9
+ # Use -f for
10
+ while getopts 'f' OPTION; do
11
+ case "$OPTION" in
12
+ f)
13
+ echo "Fix mode"
14
+ BLACK_ARGS=""
15
+ RUFF_ARGS+=" --fix"
16
+ ;;
17
+ esac
18
+ done
19
+ shift "$(($OPTIND -1))"
20
+
21
+ testheader () {
22
+ echo -e '\n'
23
+ echo "*"$emptyvar{1..20}
24
+ echo $1
25
+ echo "*"$emptyvar{1..20}
26
+ }
27
+
28
+ APPDIR=/app/src
29
+ TESTSDIR=/app/tests
30
+
31
+ testheader "black"
32
+ black $BLACK_ARGS $APPDIR $TESTSDIR
33
+
34
+ testheader "ruff"
35
+ ruff $RUFF_ARGS $APPDIR $TESTSDIR
36
+
37
+ testheader "mypy"
38
+ mypy $MYPY_ARGS $APPDIR $TESTSDIR
39
+
40
+ testheader "pytest"
41
+ pytest $PYTEST_ARGS $TESTSDIR/unit
tests/unit/test_empty_example.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ def test_nothing():
2
+ pass