Streamlit: Unable to create Pandas Series in cached functions

Created on 16 Sep 2019  路  1Comment  路  Source: streamlit/streamlit

Summary

Unable to generate Pandas Series in cached functions.

Steps to reproduce

Run this code:

import streamlit as st 
import pandas as pd

@st.cache
def test_function():
    series = pd.Series()
    return series

test_function()

Expected behavior:

Expect to be able to create Pandas Series inside of cached functions.

Actual behavior:

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)

Is this a regression?

Not sure.

Debug info

  • Streamlit version: 0.45.0
  • Python version: 3.7.4
  • Using Conda
  • OS version: Ubuntu 19.04
  • Browser version: Chrome 77.0.3865.75
bug cache

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tvst picture tvst  路  3Comments

danlester picture danlester  路  3Comments

monchier picture monchier  路  3Comments

RNogales94 picture RNogales94  路  3Comments

asemic-horizon picture asemic-horizon  路  3Comments