Skip to content

Persistent bug with caching #53

@treuille

Description

@treuille

Summary

This bug happens every time I run this uber.py script. I think it has to do with caching.

Steps to reproduce

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)

Actual behavior:

In v0.45 you will get this:
image

Note

If you hit R to rerun, you will see the right answer.

Expected behavior:

It should run properly the first time.

Is this a regression?

yes

Debug info

$ 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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:cacheRelated to `st.cache_data` and `st.cache_resource`type:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions