Version 0.64.0 β€’ Deprecation warning for st.file_uploader decoding

Version 0.64.0

Highlights:

  • :bar_chart: Default matplotlib to display charts with a tight layout. To disable this,
    set bbox_inches to None, inches as a string, or a Bbox.
  • :desktop_computer: Allow fullscreen content for Streamlit Components.
  • :card_file_box: Deprecation warning for automatic decoding on st.file_uploader.
  • :see_no_evil: If gatherUserStats is False, do not even load the Segment library.
    Thanks @tanmaylaud!

Deprecation Warning: FileUploader will no longer decode files automatically beginning after August 15th.

After the initial release of the file uploader, we’ve had great feedback from the community and are undergoing a redesign. Because there is no reliable way for us to decode files with 100% accuracy, we’ve decided to separate any decoding from the file uploader API. This means that all files will be returned as a binary buffer beginning August 15th.

What can I do?

After August 15th, 2020, your application may break depending on the type of file processing being performed. We recommend taking action now to prevent any errors once the redesigned file uploader comes out.

If you are expecting a text buffer, we recommend wrapping your returned buffer in a TextIOWrapper. This will work today, and will continue to work once the file uploader API changes. To learn more about TextIOWrapper check out the python documentation.

Current:

import io
import streamlit as st

maybe_string_io = st.file_uploader(...)
# Today, maybe_string_io is either a StringIO or a BytesIO
# depending on the uploaded file.

Recommendation:

import io
import streamlit as st

uploaded_file = st.file_uploader(...)
text_io = io.TextIOWrapper(uploaded_file)

If you are expecting uploading binary files, no action is necessary.

What if I don’t do anything?

As part of this release, st.file_uploader will now display a deprecation warning if you provide an encoding or relying on our default auto encoding. This warning can be disabled with the deprecation.showfileUploaderEncoding config option.

st.set_option('deprecation.showfileUploaderEncoding', False)

or in your .streamlit/config.toml

[deprecation]
showfileUploaderEncoding = False

Hi,
I tried to upgrade my streamlit installation (0.62.0) with the command:
pip install --upgrade streamlit.
All ok but when I run one of miy application there is an issue.
I also tried the following command: streamlit config show but there is the same issue.
Then I uninstalled and reinstalled the same version (0.64.0), but nothing has changed.
So I uninstalled the version 0.64.0 and installed the version 0.62.1.
And so everything went back to work.
I apologize for not copying the trace
Tomorrow I’ll do the operation again and copy the error.

Any ideas on how to proceed to solve the issue?

Which issue is that?
if its what i think it is try
pip3 install --upgrade protobuf

3 Likes

Hi @amitg1
This is the traceback:

Traceback (most recent call last):
  File "c:\users\mauro_s1nn2ps\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\mauro_s1nn2ps\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\mauro_s1nn2ps\AppData\Local\Programs\Python\Python37\Scripts\streamlit.exe\__main__.py", line 4, in <module>
  File "c:\users\mauro_s1nn2ps\appdata\local\programs\python\python37\lib\site-packages\streamlit\__init__.py", line 102, in <module>
    from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
  File "c:\users\mauro_s1nn2ps\appdata\local\programs\python\python37\lib\site-packages\streamlit\DeltaGenerator.py", line 41, in <module>
    from streamlit.proto import Alert_pb2
  File "c:\users\mauro_s1nn2ps\appdata\local\programs\python\python37\lib\site-packages\streamlit\proto\Alert_pb2.py", line 21, in <module>
    create_key=_descriptor._internal_create_key,
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'

I see in traceback β€œprotobuf”. You are probably right.
Now I try to upgrade protobuf

Ok, with upgrade protobuf, streamlit 0.64.0 works!

Thanks @amitg1