创建s3对象本地缓存时No Such File Error



我正在尝试使用Fsspec在AWS s3上的公共访问桶中创建数据文件的本地缓存。公共访问桶位于这里。

对我来说,在本地文件缓存中这样做是100%必要的,因为这是为了扩展,我不想物理地下载每个单独的文件。我试图通过使用底层botocore框架的API调用fsspec来做到这一点。一个简单的、最小的可复制示例如下:

进口fsspec

url = 'simplecache::s3://noaa-nbm-grib2-pds/blend.20211019/01/core/blend.20211019/01/core/blend.t01z.core.f001.co.grib2
'
of = fsspec.open_local(url, s3={'anon' : True}, filecache={'cache_storage':'/tmp/files'})

如果安装了所有依赖项,运行上述命令会重现错误。我试过用文件的复制链接地址切换url (simplecache方案是基于这里的一些fsspec文档),但仍然给出以下错误:

ValueError: open_local can only be used on a filesystem which has attribute local_file=True

是否有一个特定的url应该用于这样的东西?下面是指向对象的直接url(插入括号以防止立即下载文件的链接)

# Remove parenthesis to get full file link which is a direct file download
https://noaa-nbm-grib2-pds.s3.amazonaws.com/blend.20211019/01/core/(blend.t01z.core.f001.co.grib2)

下面的代码可以正常运行:

fsspec.open_local("simplecache::https://noaa-nbm-grib2-pds.s3.amazonaws.com/blend.20211019/01/core/blend.t01z.core.f001.co.grib2")

但是通过s3接口直接访问文件失败,使用FileNotFound。这可能表明权限没有正确设置,但是fsspec仍然像您期望的那样运行。

>>> s3 = fsspec.filesystem("s3", anon=True)
>>> s3.info("s3://noaa-nbm-grib2-pds/blend.20211019/01/core/blend.20211019/01/core/blend.t01z.core.f001.co.grib2")
FileNotFoundError

相关内容