tmontaigu / pylas

⚠️ pylas was merged into laspy 2.0 https://github.com/laspy/laspy⚠️
BSD 3-Clause "New" or "Revised" License
39 stars 13 forks source link

Reading from S3 #2

Closed mccarthyryanc closed 6 years ago

mccarthyryanc commented 6 years ago

I was trying to read LAZ files from S3, using s3fs and pylas' ability to read from streams:

import pylas
import s3fs

fs = s3fs.S3FileSystem()
las = pylas.open(fs.open('s3://bucketname/example.laz', 'rb'))

However, I get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ubuntu/miniconda3/envs/pylas-env/lib/python3.6/site-packages/pylas/lib.py", line 34, in open_las
    return read_las_stream(source)
  File "/home/ubuntu/miniconda3/envs/pylas-env/lib/python3.6/site-packages/pylas/lib.py", line 90, in read_las_stream
    vlrs = vlr.VLRList.read_from(data_stream, num_to_read=header.number_of_vlr)
  File "/home/ubuntu/miniconda3/envs/pylas-env/lib/python3.6/site-packages/pylas/vlr.py", line 571, in read_from
    raw = RawVLR.read_from(data_stream)
  File "/home/ubuntu/miniconda3/envs/pylas-env/lib/python3.6/site-packages/pylas/vlr.py", line 61, in read_from
    data_stream.readinto(header)
AttributeError: 'S3File' object has no attribute 'readinto'

Looks like s3fs doesn't have an implementation of readinto. So, is there a recommended way to read from S3? Or, should I look into getting an implementation of readinto for S3File?

tmontaigu commented 6 years ago

Ah, yes this is a change I made to try things out few days ago and encountered the same problem with s3fs but forgot to change it back. I just pushed a commit that 'fix' this b724cb2177245d1799bfb853a1bf41a2fe7dc272

mccarthyryanc commented 6 years ago

:+1: Works perfectly. Thanks for the quick fix!