danielfrg / s3contents

Jupyter Notebooks in S3 - Jupyter Contents Manager implementation
Apache License 2.0
248 stars 88 forks source link

Downloading a pickle file fails with invalid start byte #93

Closed AbdealiLoKo closed 4 years ago

AbdealiLoKo commented 4 years ago

When trying to downlaod a pickle file with s3contents, I get: 500 : invalid start byte

Steps to reproduce:

Expected Result:

Actual Result:

The logs from the server:

[I 2020-05-18 08:11:53.216 UserRunnerApp log:174] 200 GET /jupyter/user/admin/api/contents/abdealijk?type=directory&_=1589789425142 (admin@49.206.127.153) 634.75ms
[E 2020-05-18 08:11:53.907 UserRunnerApp web:1792] Uncaught exception GET /jupyter/user/admin/files/abdealijk/HighFicoLRM.pkl?download=1 (49.206.127.153)
    HTTPServerRequest(protocol='http', host='<SERVER-URL>:5000', method='GET', uri='/jupyter/user/admin/files/abdealijk/HighFicoLRM.pkl?download=1', version='HTTP/1.1', remote_ip='<IP-ADDRESS>')
    Traceback (most recent call last):
      File "/opt/jupyter/lib/python3.6/site-packages/tornado/web.py", line 1701, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/opt/jupyter/lib/python3.6/site-packages/tornado/web.py", line 3178, in wrapper
        return method(self, *args, **kwargs)
      File "/opt/jupyter/lib/python3.6/site-packages/notebook/files/handlers.py", line 57, in get
        model = cm.get(path, type='file', content=include_body)
      File "/opt/jupyter/lib/python3.6/site-packages/s3contents/genericmanager.py", line 86, in get
        return func(path=path, content=content, format=format)
      File "/opt/jupyter/lib/python3.6/site-packages/s3contents/genericmanager.py", line 98, in _get_file
        return self._file_model_from_path(path, content=content, format=format)
      File "/opt/jupyter/lib/python3.6/site-packages/s3contents/genericmanager.py", line 144, in _file_model_from_path
        content = self.fs.read(path)
      File "/opt/jupyter/lib/python3.6/site-packages/s3contents/s3_fs.py", line 186, in read
        content = f.read().decode("utf-8")
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

[E 2020-05-18 08:11:53.909 UserRunnerApp log:166] {
      "X-Forwarded-Host": "<SERVER-URL>:5000",
      "X-Forwarded-Proto": "http",
      "X-Forwarded-Port": "5000",
      "X-Forwarded-For": "49.206.127.153",
      "Cookie": "jupyterhub-user-admin=[secret]; jupyterhub-session-id=[secret]; _xsrf=[secret]",
      "Accept-Language": "en-US,en;q=0.9",
      "Accept-Encoding": "gzip, deflate",
      "Referer": "http://<SERVER-URL>:5000/jupyter/user/admin/tree/abdealijk",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
      "Dnt": "1",
      "Upgrade-Insecure-Requests": "1",
      "Connection": "close",
      "Host": "<SERVER-URL>:5000"
    }
[E 2020-05-18 08:11:53.909 UserRunnerApp log:174] 500 GET /jupyter/user/admin/files/abdealijk/HighFicoLRM.pkl?download=1 (admin@49.206.127.153) 93.69ms
AbdealiLoKo commented 4 years ago

Sorry for the noise .. Right after I created the issue, I realized I was using a very old version I was using:

s3contents (0.1.13)
s3fs (0.1.5)
jupyter (1.0.0)
jupyter-client (6.1.0)
jupyter-console (6.0.0)
jupyter-core (4.6.3)

Doing: pip install s3contents==0.4.0 s3fs==0.4.2 immediately solved the problem !