breezy-apple-27122
02/24/2023, 2:13 PMcurved-television-6568
02/24/2023, 2:31 PMbreezy-apple-27122
02/24/2023, 2:38 PMbreezy-apple-27122
02/24/2023, 2:38 PMcurved-television-6568
02/24/2023, 3:04 PMdiff --git a/requirements.txt b/requirements.txt
index 979167d..1b0ae39 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,4 +4,8 @@
ansicolors==1.1.8
setuptools>=56.2.0,<57
types-setuptools>=56.2.0,<58
-pytest==7.1.3
\ No newline at end of file
+pytest==7.1.3
+streamlit
+numpy
+pandas
+
diff --git a/streamlit/BUILD b/streamlit/BUILD
new file mode 100644
index 0000000..57aee72
--- /dev/null
+++ b/streamlit/BUILD
@@ -0,0 +1,2 @@
+python_sources()
+pex_binary(name="bin", script="streamlit", dependencies=["./demo.py"])
diff --git a/streamlit/BUILD~ b/streamlit/BUILD~
new file mode 100644
index 0000000..db46e8d
--- /dev/null
+++ b/streamlit/BUILD~
@@ -0,0 +1 @@
+python_sources()
diff --git a/streamlit/demo.py b/streamlit/demo.py
new file mode 100644
index 0000000..b891ac3
--- /dev/null
+++ b/streamlit/demo.py
@@ -0,0 +1,36 @@
+import streamlit as st
+import pandas as pd
+import numpy as np
+
+st.title('Uber pickups in NYC')
+
+DATE_COLUMN = 'date/time'
+DATA_URL = ('<https://s3-us-west-2.amazonaws.com/>'
+ 'streamlit-demo-data/uber-raw-data-sep14.csv.gz')
+
+@st.cache_data
+def load_data(nrows):
+ data = pd.read_csv(DATA_URL, nrows=nrows)
+ lowercase = lambda x: str(x).lower()
+ data.rename(lowercase, axis='columns', inplace=True)
+ data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
+ return data
+
+data_load_state = st.text('Loading data...')
+data = load_data(10000)
+data_load_state.text("Done! (using st.cache_data)")
+
+if st.checkbox('Show raw data'):
+ st.subheader('Raw data')
+ st.write(data)
+
+st.subheader('Number of pickups by hour')
+hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
+st.bar_chart(hist_values)
+
+# Some number in the range 0-23
+hour_to_filter = st.slider('hour', 0, 23, 17)
+filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
+
+st.subheader('Map of all pickups at %s:00' % hour_to_filter)
+st.map(filtered_data)
diff --git a/streamlit/demo.py~ b/streamlit/demo.py~
new file mode 100644
index 0000000..e69de29
$ pants run streamlit:bin -- run streamlit/demo.py
2023-02-24 09:59:45.409 WARNING streamlit.config:
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.
More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
๐ Welcome to Streamlit!
If you're one of our development partners or you're interested in getting
personal technical support or Streamlit updates, please enter your email
address below. Otherwise, you may leave the field blank.
Email:
Privacy Policy:
As an open source project, we collect usage statistics. We cannot see and do
not store information contained in Streamlit apps. You can find out more by
reading our privacy policy at: <https://streamlit.io/privacy-policy>
If you'd like to opt out of usage statistics, add the following to
~/.streamlit/config.toml, creating that file if necessary:
[browser]
gatherUsageStats = false
2023-02-24 09:59:56.323 DEBUG streamlit.web.bootstrap: Setting up signal handler
2023-02-24 09:59:56.323 DEBUG asyncio: Using selector: KqueueSelector
2023-02-24 09:59:56.324 DEBUG streamlit.web.server.server: Starting server...
2023-02-24 09:59:56.324 DEBUG streamlit.web.server.server: Serving static content from the Node dev server
2023-02-24 09:59:56.367 DEBUG streamlit.web.server.server: Server started on port 8501
2023-02-24 09:59:56.367 DEBUG streamlit.web.server.server: Server state: State.INITIAL -> State.WAITING_FOR_FIRST_SESSION
2023-02-24 09:59:56.726 DEBUG git.cmd: Popen(['git', 'version'], cwd=/Users/andreas.stenius/src/github/kaos/example-python, universal_newlines=False, shell=None, istream=None)
2023-02-24 09:59:56.744 DEBUG git.cmd: Popen(['git', 'version'], cwd=/Users/andreas.stenius/src/github/kaos/example-python, universal_newlines=False, shell=None, istream=None)
2023-02-24 09:59:56.755 DEBUG git.util: Failed checking if running in CYGWIN due to: FileNotFoundError(2, 'No such file or directory')
2023-02-24 09:59:56.848 DEBUG git.cmd: Popen(['git', 'version'], cwd=/Users/andreas.stenius/src/github/kaos/example-python, universal_newlines=False, shell=None, istream=None)
2023-02-24 09:59:56.859 DEBUG git.cmd: Popen(['git', 'rev-parse', '--show-toplevel'], cwd=/Users/andreas.stenius/src/github/kaos/example-python, universal_newlines=False, shell=None, istream=None)
You can now view your Streamlit app in your browser.
Local URL: <http://localhost:3000>
Network URL: <http://10.0.0.62:3000>
For better performance, install the Watchdog module:
$ xcode-select --install
$ pip install watchdog
2023-02-24 09:59:56.893 DEBUG streamlit.version: Skipping PyPI version check
^C Stopping...
2023-02-24 10:02:23.039 DEBUG streamlit.web.server.server: Server state: State.WAITING_FOR_FIRST_SESSION -> State.STOPPING
2023-02-24 10:02:23.040 DEBUG streamlit.web.server.server: Server state: State.STOPPING -> State.STOPPED
Interrupted by user.
breezy-apple-27122
02/24/2023, 3:07 PMscript="streamlit"
to use a cli command!curved-television-6568
02/24/2023, 3:08 PMbreezy-apple-27122
02/24/2023, 3:09 PMbreezy-apple-27122
02/24/2023, 3:09 PMcurved-television-6568
02/24/2023, 3:26 PMcurved-television-6568
02/24/2023, 3:36 PMrun streamline/demo.py
directly in the BUILD file..curved-television-6568
02/24/2023, 3:37 PMbreezy-apple-27122
02/27/2023, 7:49 AMbreezy-apple-27122
02/27/2023, 7:49 AMrhuan@Rhuans-Laptop python % ./pants run src/streamlit/template:bin -- run streamlit/main.py
pyenv: python3.11: command not found
The `python3.11' command exists in these Python versions:
3.11.1
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
breezy-apple-27122
02/27/2023, 8:59 AMbreezy-apple-27122
02/27/2023, 8:59 AMbreezy-apple-27122
02/27/2023, 9:24 AMbreezy-apple-27122
02/27/2023, 9:24 AMglamorous-nail-59544
10/12/2023, 2:56 PMpowerful-scooter-95162
11/08/2023, 7:11 PMpex_binary(
name="dashboard",
execution_mode="venv",
script="streamlit",
args=["run", "ux/dashboard.py"],
dependencies=["//ux/dashboard.py", "//:root#streamlit"],
)
And then I can run ./dist/ux/dashboard.pex