admin管理员组文章数量:1296391
I have a helper function need to run in every task to init environment.
The problem is, task can not access any variable out of it self's scope. So I have to add the same code to the beginning of every task, like:
@task.external_python(
python=v_python_path,
retries=3,
)
def init_env():
### this part have to be added for every task
import sys
sys.path.append("/opt/airflow/dags")
####
from my_module import my_function
Is there a way to make it cleaner and graceful?
本文标签:
版权声明:本文标题:python - How to call helper functions from task.external_python in dag without set sys.path everytime? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741619917a2388748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论