Skip to content

Python: Missing methods on async_tiff.store classes #111

@maxrjones

Description

@maxrjones

I'd like to be able to cache a file in a MemoryStore for use with async_tiff, but am blocked by the lack of public get methods on the async_tiff store classes. Would it be possible to expose the get and put methods?

For example:

from urllib.parse import urlparse
import async_tiff as atiff
import asyncio
import obstore

async def open_tiff(*, urlpath: str, store: atiff.store.MemoryStore) -> atiff.TIFF:
    return await atiff.TIFF.open(urlpath, store=store)

url = "https://github.com/mdsumner/rema-ovr/raw/refs/heads/main/rema_mosaic_1km_v2.0_filled_cop30_dem.tif"
parsed = urlparse(url)
urlpath = parsed.path

# Cache in memory using async_tiff
https_store = atiff.store.HTTPStore.from_url(f"{parsed.scheme}://{parsed.netloc}")
memory_store = atiff.store.MemoryStore()
print(dir(memory_store))
print(dir(obstore.store.MemoryStore()))
buffer = https_store.get(urlpath).bytes()
memory_store.put(urlpath, buffer)
asyncio.run(open_tiff(urlpath, memory_store))
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', 'copy', 'copy_async', 'delete', 'delete_async', 'get', 'get_async', 'get_range', 'get_range_async', 'get_ranges', 'get_ranges_async', 'head', 'head_async', 'list', 'list_with_delimiter', 'list_with_delimiter_async', 'put', 'put_async', 'rename', 'rename_async']
    buffer = https_store.get(urlpath).bytes()
             ^^^^^^^^^^^^^^^
AttributeError: 'builtins.HTTPStore' object has no attribute 'get'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions