kedro ossfs 支持说明

kedro 是基于fsspec 进行内部文件处理的,但是在对于是cloud remote 文件系统的时候是基于白名单处理的有缺陷,对于oss 支持就有问题(比如解析bucket),解决方法很多,一种是直接修改kedro.io.core 中的CLOUD_PROTOCOLS,还有一种就是通过python 的猴子补丁模式,比较快速

修改方法

  • 猴子补丁模式参考修改
    可以直接在pipeline 项目中的 pipeline_registry.py 中进行修改,如下
from  kedro.io import core
core.CLOUD_PROTOCOLS  = ("s3","oss","s3n", "s3a", "gcs", "gs", "adl", "abfs", "abfss", "gdrive")

这样项目模块中的CLOUD_PROTOCOLS 就包含了oss 了,支持就可以了

  • 源码直接修改
    就是修改kedro.io import core 中的CLOUD_PROTOCOLS 添加oss 等

说明

目前官方kedro 我也已经发了一个pr,等待review

参考资料

https://github.com/fsspec/ossfs
https://docs.kedro.org/en/stable/data/data_catalog.html
https://dev.to/karishmashukla/monkeying-around-with-python-a-guide-to-monkey-patching-obc
https://github.com/GrahamDumpleton/wrapt/blob/develop/blog/11-safely-applying-monkey-patches-in-python.md
https://machinelearningmastery.com/monkey-patching-python-code/
https://medium.com/@bits_code/https-medium-com-bits-code-monkey-patching-in-python-9a28dc0cbe4f

posted on 2024-10-05 06:27  荣锋亮  阅读(0)  评论(0编辑  收藏  举报

导航