如何在带缓存的fsspec中传递AWS profile_name参数?
解决fsspec filecache模式下传递AWS Profile参数无效的问题
当使用fsspec的filecache封装S3文件系统时,直接在filesystem()方法中传递profile参数是无效的——这类S3专属参数需要通过target_options字典传递给底层的s3文件系统实现。
正确的写法是将profile等S3相关参数放入target_options中:
fs = fsspec.filesystem( "filecache", target_protocol="s3", cache_storage="some/dir", cache_check=10, expiry_time=60, target_options={"profile": profile_name} )
这样filecache会把target_options中的参数传递给底层的s3fs.S3FileSystem实例,既实现了profile的配置,又保留了缓存功能。
这种方式适用于所有需要传递给目标协议文件系统的专属参数,比如endpoint_url、aws_access_key_id等S3相关配置,都可以放在target_options字典里统一传递。
内容的提问来源于stack exchange,提问作者Roelant
相关产品推荐
相关产品推荐

