streamlit / streamlit Goto Github PK
View Code? Open in Web Editor NEWStreamlit — A faster way to build and share data apps.
Home Page: https://streamlit.io
License: Apache License 2.0
Streamlit — A faster way to build and share data apps.
Home Page: https://streamlit.io
License: Apache License 2.0
Unable to generate Pandas Series in cached functions.
Run this code:
import streamlit as st
import pandas as pd
@st.cache
def test_function():
series = pd.Series()
return series
test_function()
Expect to be able to create Pandas Series inside of cached functions.
Following error is thrown:
TypeError: stat: path should be string, bytes, os.PathLike or integer, not property
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/ScriptRunner.py", line 317, in _run_script exec(code, module.__dict__)
File "/home/jforth/Documents/streamlit_test.py", line 9, in <module> test_function()
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/caching.py", line 393, in wrapped_func code_hasher.update(func)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 159, in update self._update(self.hasher, obj, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 190, in _update b = self.to_bytes(obj, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 179, in to_bytes b = self._to_bytes(obj, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 259, in _to_bytes h.update(self._code_to_bytes(obj.__code__, context))
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 316, in _code_to_bytes self._update(h, ref, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 190, in _update b = self.to_bytes(obj, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 179, in to_bytes b = self._to_bytes(obj, context)
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/site-packages/streamlit/hashing.py", line 236, in _to_bytes isinstance(obj, io.IOBase) or os.path.exists(obj.name)):
File "/home/jforth/anaconda3/envs/AutoDraft/lib/python3.7/genericpath.py", line 19, in exists os.stat(path)
Not sure.
import streamlit as st
end = int(st.sidebar.text_input('Input:', '10'))
slider_output = st.sidebar.slider('slider', 0, end, 0)
st.write(selected_frame_index)
10
and move the slider all the way to the right. The number 10
should appear in the main columnThe value in the main column is 10
The value in the main column should not be 10, but it should be within the bounds of the slider
We're using ReactVirtualized which is built for handling long lists but we're only using the AutoSizer component which handles resizing width or height.
Perhaps using a List component inside the AutoSizer is necessary to trigger long list handling.
WebsocketConnection.handleMessage
can throw errors for a variety of reasons. We're currently swallowing those errors, which leaves a running report in a broken state.
(We may want to just move to the "disconnected forever" state and tell the user that everything blew up.)
Broke after creating the new Streamlit repo. Test runs aren't being recorded even though I have the record key
environment variable set both in my personal CircleCI and in the Streamlit org CircleCI.
How: move write
away from __init__.py
and into the DeltaGenerator
class.
When I have two date widgets in the sidebar it is positioning one under the other. See photo attached.
What are the steps we should take to reproduce the bug:
st.sidebar.date_input('start date', datetime.date(2011,01,01))
st.sidebar.date_input('end date', datetime.date(2011,12,31))
When widget is open it should pop over anything else in the sidebar until it is closed.
Shows underneath the other widget.
Unclear
Cache issue found with the self-driving car demo
In Chrome, you can blink the tab title by setting window.title
to anything while the tab is inactive.
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
Is it possible to run cypress tests in parallel using the node module api and calling a single spec per cypress run?
Pandas supports a Categorical Index datatype. When using st.write(dataframe)
, if the dataframe contains some categorical data an error is generated.
Create a dataframe with a Categorical Index. For example: uses pd.cut
to segment existing numerical data (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.cut.html)
This is a snippet that takes a median_income column and segments it (from https://github.com/ageron/handson-ml/blob/master/02_end_to_end_machine_learning_project.ipynb row 22)
No error. The dataframe is shown in the UI.
st.write(df['income_cat'])
NotImplementedError: Can't handle <class 'pandas.core.indexes.category.CategoricalIndex'> yet.
st.write(df['income_cat'].value_counts())```
## Is this a regression?
Not that I know
# Debug info
- Streamlit version: Streamlit v0.45.0
- Python version: 3.7.4
- Using Conda? PipEnv? PyEnv? Pex?
- OS version: MacOs 10.14.6
- Browser version: Chrome 76.0.3809.100
# Additional information
If needed, add any other context about the problem here.
For example, textual dataframe with non utf-8 encoding.
Should we run gc.collect()
after ScriptRunner completes (possibly only if no other ScriptRunners are active)?
(This may help with e.g. the tensorflow memory issues Armando was seeing in the Shaobo demo.)
The text in the title of a selectbox seems smaller than other text.
Create a selectbox and render it.
('LinearRegression', 'DecisionTreeRegressor', 'RandomForestRegressor', 'LinearSVR'))
The size of the text in Which model do you want to use? is similar to the text in the options.
The size of the text for Which model do you want to use? is smaller
That is, did this use to work the way you expected in the past?
yes / no
If needed, add any other context about the problem here.
Need a better warning for when passing a full dataframe to st.selectbox. It says Warning:0. I had assumed that since it was only one column it would be fine, so we need to note that they need to pass through the column.
The hamburger menu in the upper right could be improved to:
Happily, the solution is mostly a reordering of the present menu! I propose the following:
Menu Item | Shortcut | Action | Note |
---|---|---|---|
Rerun | r | Rerun the script | |
Clear cache | c | Clear the cache | |
Settings | Go to the settings menu | ||
--- | --- | [Horizontal rule] | --- |
Documentation | streamlit.io/docs | ||
Ask a question | discuss.streamlit.io/c/Questions | ||
Submit a bug | github.com/streamlit/streamlit/issues/new?assignees=&labels=bug&template=bug_report.md&projects=streamlit/1&title= | This will automatically populate the Projects field correctly. | |
Request a feature | github.com/streamlit/streamlit/issues/new?assignees=&labels=enhancement&template=feature_request.md&projects=streamlit/1&title= | This will automatically populate the Projects field correctly. | |
--- | --- | [Horizontal rule] | --- |
Community | discuss.streamlit.io | ||
Streamlit for teams | streamlit.io/teams | ||
About | Display the about menu |
Note: This removes the Edit command menu item which is a security risk.
We should not do this, but for the record, here are some fun emojis we could consdier at some point if the design accomodated it.
Menu Item |
---|
🏃🏽Rerun |
😳Clear cache |
⚙️Settings |
--- |
❓Documentation |
🙋🏽Ask a question |
🐞Submit a bug |
🎁Request a feature |
--- |
🍻Community |
👩🏽💻Streamlit for teams |
📜About |
I'd like to run several Streamlit apps simultaneously on the same computer, each with its own port.
Parse ./.streamlit/config.toml
in the current directory. This should be parsed after ~/.streamlit/config.toml
in the home directory, and overrride any settings there.
If ~/.streamlit/config.toml
contains:
[runner]
magicEnabled = true
[server]
port = 6789
and ./.streamlit/config.toml
contains:
[server]
port = 9999
then the final config would be equivalent to:
[runner]
magicEnabled = true
[server]
port = 9999
Ultimately, we should also allow the user to set config options on the command line.
Call jslint in different ways, to record to file in circleci, and to log to console in development
Goal is to have an environment that we can run Cypress tests in that matches the CircleCI environment
It is annoying when I already have Streamlit running in one terminal which blocks the port and prevents Streamlit from running in another port.
streamlit run foo.py
streamlit run bar.py
What happens: the second Streamlit call fails to run because the port is already taken
Desired: we somehow switch ports
When the port is already taken, print this to the terminal:
ERROR: Port %(port)s is already in use.
Please enter another port, or press Enter to exit:
Then, on Enter
:
"%(input)s" is not a valid port.
Please enter another port, or press Enter to exit:
In our old repo we have a larger discussions around this. We may want to implement some of those solutions later. But for now, let's just do the MVP above.
When the user first runs a streamlit foo
command on the CLI, we currently show a message asking for the user's email:
Enter your email for access to our beta
and then show a welcome message:
Welcome to Streamlit!
Get started by typing:
$ streamlit hello
This was fine for our beta, but for a public launch we should:
Replace the first message with:
👋 Welcome to Streamlit! [in green]
If you are one of our development partners or are interested in
getting personal technical support, please enter your email address
below. Otherwise, you may leave the field blank.
Email:
and the second with:
Telemetry: as an open source project, we use collect summary
statistics and metadata to understand how people are using Streamlit.
If you'd like to opt out, add the following to ~/.streamlit/config.toml,
creating that file if necessary:
[browser]
gatherUsageStats = false
(leave the first and last lines in this block blank, so it doesn't touch any text we print above or below it.)
This causes sliders to jump up/down when you drag the thumb over certain slider positions.
When the user types streamlit run foo.py
, check whether a new version of Streamlit is available in PyPI and, if so, print the following message to the terminal:
A new version of Streamlit is available. [in bold white]
See what's new at https://streamlit.trydiscourse.com/c/announcements
Enter the following command to upgrade:
$ pip install streamlit --upgrade [in green]
Notes:
click
package to print in color.st.cache
with persist
to cache the update-checking function to disk, and add a max_age
parameter to st.cache
that lets you set an age at which the cache becomes invalid.cli.py
inside _main_run()
.Some Vega lite charts have gotten very skinny
When running streamlit with a package:
streamlit -m package
Messaging in the UI should reflect this command line.
https://docs.cypress.io/guides/guides/parallelization.html#Grouping-test-runs
Multiple use cases possible, but since we run individual specs in our test runner, we can group the individual runs under a single group so they appear under a single parent run in the cypress dashboard.
A DataFrame
which contains a list is unhashable and therefore breaks st.cache
.
Run this code
import streamlit as st
import pandas as pd
@st.cache
def return_a_list(n):
return pd.DataFrame({'n': [n], 'result': [list(range(n))]})
st.text(return_a_list(10))
We get an error with the following stack trace
TypeError: unhashable type: 'list'
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/ScriptRunner.py", line 317, in _run_script exec(code, module.__dict__)
File "/Users/adrien/Desktop/streamlit/streamlit-staging/test_list_bug.py", line 9, in <module> st.text(return_a_list(10))
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/caching.py", line 412, in wrapped_func key, return_value, persist, ignore_hash, args_mutated)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/caching.py", line 307, in _write_to_cache _write_to_mem_cache(key, value, ignore_hash, args_mutated)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/caching.py", line 237, in _write_to_mem_cache hash=None if ignore_hash else get_hash(value),
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/hashing.py", line 89, in get_hash hasher.update(f, context)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/hashing.py", line 159, in update self._update(self.hasher, obj, context)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/hashing.py", line 190, in _update b = self.to_bytes(obj, context)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/hashing.py", line 179, in to_bytes b = self._to_bytes(obj, context)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/streamlit/hashing.py", line 230, in _to_bytes return pd.util.hash_pandas_object(obj).sum()
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/util/hashing.py", line 115, in hash_pandas_object h = _combine_hash_arrays(hashes, num_items)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/util/hashing.py", line 41, in _combine_hash_arrays for i, a in enumerate(arrays):
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/util/hashing.py", line 104, in <genexpr> hashes = (hash_array(series.values) for _, series in obj.iteritems())
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/util/hashing.py", line 286, in hash_array codes, categories = factorize(vals, sort=False)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/util/_decorators.py", line 178, in wrapper return func(*args, **kwargs)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/algorithms.py", line 630, in factorize na_value=na_value)
File "/Users/adrien/.pyenv/versions/3.6.3/envs/streamlit-staging/lib/python3.6/site-packages/pandas/core/algorithms.py", line 476, in _factorize_array na_value=na_value)
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_labels
This should work, just as if return_a_list
weren't decorated with @st.cache
.
Not sure.
$ streamlit version && python --version && pyenv --version && sw_vers && "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version
Streamlit, version 0.45.0
Python 3.6.3
pyenv 1.2.3
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G95
Google Chrome 76.0.3809.132
streamlit run foo.py
foo.py
app in itctrl-c
's out of the server, but leaves the tab open.foo.py
. So she calls streamlit run foo.py
...and then nothing happens. No new browser tab opens, because the tab from (1) is already connected to the new Streamlit server. And the existing tab doesn't come to the top. So the user has no idea where the app loaded.
Show a notification at step (4), saying:
App
yourscript.py
is ready.
Click here to see it.
On click, the browser with the Streamlit tab comes to the front and the tab becomes active.
This behavior should be configurable with:
[browser]
showNotificationIfTabInactive = false
The new menu should look like
Rerun
Edit command
Clear cache
---
Documentation [links to streamlit.io/docs]
Community [links to discuss.streamlit.io]
Streamlit for teams [links to streamlit.io/teams]
---
Report a bug [links to https://github.com/streamlit/streamlit/issues/new/choose]
---
Settings
About
I want to have two date inputs and only have the code rerun after I have finished changing both. A date range slider is the best solution, but I can imagine other situations where I'd want to change multiple inputs before re-running -- like in Project Orient.
Would be nice to have a way to set it up with st.button so that only on button push does it rerun the code.
If you name, for example, two buttons 'abc'
, you will get some weird behavior (see below).
To avoid this, we should ensure that no two widgets have the same name by raising an exception should the user violate this rule.
Run the following code:
import streamlit as st
if st.button('abc'):
st.success('First button fired.')
if st.button('abc'):
st.success('Second button fired.')
The button appears twice (no exceptions thrown):
and when you click the button, it fires twice:
The second button named 'abc'
should raise an exception.
Not sure.
$ streamlit version && python --version && pyenv --version && sw_vers && "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version
Streamlit, version 0.45.0
Python 3.6.5
pyenv 1.2.3
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G84
Google Chrome 76.0.3809.132
Try this without Streamlit:
for i in range(1000):
print(i)
print('done')
Result: script prints 'done' within a few dozens of milliseconds
Now try this with Streamlit:
import streamlit as st
for i in range(1000):
st.write(i)
st.write('done')
Result: script takes several dozens of seconds to print 'done' on the report.
Finally, try this with Streamlit:
import streamlit as st
import time
start_time = time.time()
for i in range(1000):
st.write(i)
end_time = time.time()
st.write('Total time is', end_time - start_time)
Result: script takes several dozens of seconds to print 'done' on the report, but it prints the total time in the terminal in only a few hundred milliseconds. So the problem is between the Server and the browser.
This bug happens every time I run this uber.py
script. I think it has to do with caching.
Run this uber.py
file:
import streamlit as st
import pandas as pd
import numpy as np
DATE_TIME = 'date/time'
DATA_URL = 'https://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz'
lowercase = lambda x: str(x).lower()
@st.cache
def load_data(nrows):
data = pd.read_csv(DATA_URL, nrows=nrows)
data.rename(lowercase, axis='columns', inplace=True)
data[DATE_TIME] = pd.to_datetime(data[DATE_TIME])
data['hour'] = (data[DATE_TIME].dt.hour + 17) % 24
return data
data = load_data(100000)
hour = st.slider('hour', 0, 23, 11)
data = data[data[DATE_TIME].dt.hour == hour]
st.write('### Geo Data at %sh' % hour)
midpoint = (np.average(data['lat']), np.average(data['lon']))
st.deck_gl_chart(
viewport={
'latitude': midpoint[0],
'longitude': midpoint[1],
'zoom': 11,
'pitch': 50,
},
layers=[{
'type': 'HexagonLayer',
'data': data,
'radius': 100,
'elevationScale': 4,
'elevationRange': [0, 1000],
'pickable': True,
'extruded': True,
}])
st.write('### Data by Minute at %sh' % hour)
st.bar_chart(np.histogram(data[DATE_TIME].dt.minute, bins=60)[0])
if st.checkbox("Show Raw Data"):
st.write('### Raw Data at %sh' % hour)
st.write(data)
If you hit R
to rerun, you will see the right answer.
It should run properly the first time.
yes
$ streamlit version && python --version && pyenv --version && sw_vers && "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version
Streamlit, version 0.45.0
Python 3.6.3
pyenv 1.2.3
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G95
Google Chrome 76.0.3809.132
Steps to repro:
examples/reference.py
Expected: on rerun, all elements fade out and then become opaque one by one even before the run is done.
Actual: on rerun, all elements fade out and only become opaque when the entire run is done.
I believe this bug was introduced with the Sidebar code.
Task: verify that you can run all examples and e2e scripts using "python foo.py", and fix any bugs that arise
React doesn't bundle renders for new delta msgs
no bundling of setState calls outside of event handlers
https://itnext.io/react-setstate-usage-and-gotchas-ac10b4e03d60
consider debouncing render calls, https://github.com/podefr/react-debounce-render/tree/master/src
consider batching writes to the state
When editing code and saving in my IDE with Always Run enabled, the rerun is not immediately kicked off, but it seems I have to click on the Streamlit UI in the browser.
I expect to see the Streamlit UI re-generate the results every time I save.
Nothing happens on the UI. If click on the UI, the computation starts and results are regenerated.
That is, did this use to work the way you expected in the past?
N/A
Low priority issue
st.selectbox throws an error when you pass it a dataframe even if that df only has one column.
It should detect if you are passing a dataframe with only one column and accept that.
Streamlit watches files in the current folder for changes by using one of two methods:
watchdog
Python module, which uses OS-level event-based APIsIf the watchdog
module is available on the user's system, we currently use Method 1. If not, we use Method 2.
The problem is that the watchdog
module it compiled locally by Pip when the user pip-installs it -- and on a Mac this compilation step requires the free XCode CLI tools with:
xcode-select --install
So what we'd like to do is:
setup.py
so we check whether xcode tools are available before making watchdog
a dependency (only if the current system is a Mac, of course).LocalSourcesWatcher.py
, when we fall back to the polling solution, print a message telling the user to install the watchdog module (see below).global.disableWatchdogWarning
Message:
For better performance, install the Watchdog module:
$ xcode-select --install [only show this message if on a Mac]
$ pip install watchdog
(leave a blank line at the end, so the message does not merge with whatever we print after it.)
Speed improvement
With version 4, plotly has moved all online features to a new chart-studio package.
What are the steps we should take to reproduce the bug:
Plotly should be imported for use with st.plotly_chart()
Plotly is unable to be imported.
Functions as expected with plotly 3.10.
Not the end of the world as 3.10 is still working; was curious if there is a way to include the necessary version of plotly as a dependency somewhere.
The altair chart is using vega lite under the hood now and the chart's height has changed
Background: HighCharts is a JS plotting library, but there is a wrapper for Python: https://github.com/kyper-data/python-highcharts
API Spec: Unclear at this point. As part of this work we'll have to research how HighCharts works (I'm not familiar with it myself) and come up with a nice API within Streamlit.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.