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

open_rasterio fails when lock=True #273

Closed
jessjaco opened this issue Mar 11, 2021 · 1 comment · Fixed by #274
Closed

open_rasterio fails when lock=True #273

jessjaco opened this issue Mar 11, 2021 · 1 comment · Fixed by #274
Labels
bug Something isn't working

Comments

@jessjaco
Copy link

jessjaco commented Mar 11, 2021

https://corteva.github.io/rioxarray/stable/rioxarray.html#rioxarray-open-rasterio says using open_rasterio with lock=True is valid, but doing so gives an error. This option is also described in https://corteva.github.io/rioxarray/stable/examples/read-locks.html.

import rioxarray

url = (
    "https://naipeuwest.blob.core.windows.net/naip/v002/md/2013/md_100cm_2013/"
    "39076/m_3907617_ne_18_1_20130924.tif"
)
ds = rioxarray.open_rasterio(url, lock=True, chunks=(4, "auto", -1))

Output:

   File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.8/site-packages/rioxarray/_io.py", line 751, in open_rasterio
    riods = manager.acquire()
  File "/venv/lib/python3.8/site-packages/xarray/backends/file_manager.py", line 181, in acquire
    file, _ = self._acquire_with_cache_info(needs_lock)
  File "/venv/lib/python3.8/site-packages/xarray/backends/file_manager.py", line 197, in _acquire_with_cache_info
    with self._optional_lock(needs_lock):
  File "/opt/conda/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/venv/lib/python3.8/site-packages/xarray/backends/file_manager.py", line 161, in _optional_lock
    with self._lock:
AttributeError: __enter__

Using
ubuntu 20.04
rioxarray==0.3.1
xarray==0.17.0

@jessjaco jessjaco added the bug Something isn't working label Mar 11, 2021
@snowman2
Copy link
Member

For reference for those who run into this, this was added in #214

True is not a valid option and should instead not pass anything in.

Examples of how to pass in locks: https://corteva.github.io/rioxarray/stable/examples/dask_read_write.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants