使用Apache Airflow Tool,为批处理管道实现DAG,以从远程系统获取目录

问题描述

使用Apache airflow工具,如何为以下Python代码实现DAG。代码中完成的任务是将目录从GPU服务器获取到本地系统。代码在Jupyter笔记本中运行正常。请帮助在Airflow中实施...我对此很陌生。谢谢。

import pysftp
import os
myHostname = "hostname"
myUsername = "username"
myPassword = "pwd"

with pysftp.Connection(host=myHostname,username=myUsername,password=myPassword) as sftp:
    print("Connection successfully stablished ... ")
    src = '/path/src/'
    dst = '/home/path/path/destination'
    os.mkdir(dst)
    sftp.get_d(src,dst,preserve_mtime=True)
    print("Fetched source images from GPU server to local directory")
# connection closed automatically at the end of the with-block```

解决方法


  • 我承认并没有很多例子,但是this可能会有帮助
  • 有关SSH连接的信息,请参见this