除了 subprocess.Open 之外,有什么方法可以从 python 调用 "hadoop cp/distcp" 吗?
Is there any way to call "hadoop cp/distcp" from python except subprocess.Open?
我需要使用 python 定期将文件从本地集群移动到 GCP 并返回。
虽然 hdfs
seem fine to me for discovering directories structure, I found out that it does not provide "copy" option (limitations of WebHDFS,据我了解)。
在选择 之前,是否有其他方法(例如一些 python API)将文件从一个位置复制到另一个位置?
在寻找答案时,我发现至少有两个可能的选择:Pydoop and pydistcp。
尽管如此,我还是决定在我的案例中使用 subprocess
:
from subprocess import check_call
def distcp(from_path: str, to_path: str) -> None:
check_call(['hadoop', 'distcp', from_path, to_path], stderr=subprocess.STDOUT)
据我所知,Pydoop reads and writes files via local buffer,同样适用于 pydistcp,在大文件(千兆字节)的情况下不如 MR 作业有效。
也许可以通过 Pydoop MR API 运行 distcp
,但这样的解决方案远非简单和可维护的。
我需要使用 python 定期将文件从本地集群移动到 GCP 并返回。
虽然 hdfs
seem fine to me for discovering directories structure, I found out that it does not provide "copy" option (limitations of WebHDFS,据我了解)。
在选择
在寻找答案时,我发现至少有两个可能的选择:Pydoop and pydistcp。
尽管如此,我还是决定在我的案例中使用 subprocess
:
from subprocess import check_call
def distcp(from_path: str, to_path: str) -> None:
check_call(['hadoop', 'distcp', from_path, to_path], stderr=subprocess.STDOUT)
据我所知,Pydoop reads and writes files via local buffer,同样适用于 pydistcp,在大文件(千兆字节)的情况下不如 MR 作业有效。
也许可以通过 Pydoop MR API 运行 distcp
,但这样的解决方案远非简单和可维护的。