Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stor needs to pass 'rb' flag to dxpy #108

Open
ying-w opened this issue Feb 21, 2019 · 1 comment
Open

stor needs to pass 'rb' flag to dxpy #108

ying-w opened this issue Feb 21, 2019 · 1 comment

Comments

@ying-w
Copy link
Contributor

ying-w commented Feb 21, 2019

Currently on python3 if you're trying to stor.open() a file a DNAnexus, it will give a unicode error if you're opening a non-text (binary file).

Recently a PR was merged that adds an 'rb' mode for dxpy. Thus read_object() function in dx.py needs to be updated to reflect this.

For example, given a .png file that you want to view within jupyter notebook with DNAnexus id: project-abc:file-xyz

import stor
import dxpy
from PIL import Image

img = stor.Path('dx://project-abc:file-xyz')
with stor.open(img, "rb") as f:
    display(Image.open(io.BytesIO(f.read()))) # this will give UnicodeDecodeError

with dxpy.DXFile(dxid='file-xyz', project='project-abc', mode='rb') as dp:
    display(Image.open(io.BytesIO(dp.read()))) # this will work

dxpy.__version__ # '0.277.0+g18cd5634'
@jtratner
Copy link
Collaborator

@anujkumar93 - looks like they updated the underlying API - we should update for Python 3 so we can support text files!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants