云作曲家(气流)运行依赖的python脚本

发布于 2025-02-09 03:46:11 字数 271 浏览 2 评论 0 原文

Python Project正在运行多个PY脚本。是否可以从DAG中调用其他Python脚本,而是从单个Python脚本中调用DAG中的一个Python脚本,即通过Pythonoperator或气流中的Bashoperator在DAG中提到的部分。

例如,我想使用test.py调用其他Python脚本

curl = BashOperator(
task_id='multiplescripts',
bash_command="test.py",
dag=dag)

Python project is running multiple py scripts. Is it possible call other python scripts not from DAG but from a single python script i.e. part-of/mentioned in DAG via PythonOperator or BashOperator in Airflow.

For example I want to call other python scripts using test.py

curl = BashOperator(
task_id='multiplescripts',
bash_command="test.py",
dag=dag)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你丑哭了我 2025-02-16 03:46:11

PythOnoperator用于执行Python可叫。如果您要执行Python脚本,而不仅仅是使用适当的bash命令:

python test.py

因此,操作员将是:

curl = BashOperator(
    task_id='multiplescripts',
    bash_command="python test.py",
    dag=dag
)

PythonOperator is used to execute a python callable. If you want to execute a python script than just use the the proper bash command:

python test.py

so the operator would be:

curl = BashOperator(
    task_id='multiplescripts',
    bash_command="python test.py",
    dag=dag
)
久而酒知 2025-02-16 03:46:11

您可以致电pythontoerator。像这样,

def testfunction(text):
    return

test_task = PythonOperator(
                task_id="test_function",
                python_callable=testfunction,
                op_args=[ 'we are calling the function' ],
            )

您可以看到文档

You can call the PythonOperator. Like that

def testfunction(text):
    return

test_task = PythonOperator(
                task_id="test_function",
                python_callable=testfunction,
                op_args=[ 'we are calling the function' ],
            )

You can see the documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文