Python项目正在运行多个py脚本。是否有可能从DAG中调用其他python脚本,而是从单个python脚本中调用,即通过气流中的PythonOperator或BashOperator在DAG中提到的部分。
例如,我想使用test.py
调用其他python脚本curl = BashOperator(
task_id='multiplescripts',
bash_command="test.py",
dag=dag)
PythonOperator用于执行python可调用对象。如果您想执行python脚本,只需使用适当的bash命令:
python test.py
所以运算符是:
curl = BashOperator(
task_id='multiplescripts',
bash_command="python test.py",
dag=dag
)
你可以调用PythonOperator。这样的
def testfunction(text):
return
test_task = PythonOperator(
task_id="test_function",
python_callable=testfunction,
op_args=[ 'we are calling the function' ],
)
您可以查看文档