airflow 版本: 1.10.1
- 可以 pip 安装后修改 site-packages 下的代码
- 也可以去 github 下载源码,修改好后,python setup.py install 安装
原文链接:https://blog.csdn.net/crazy__hope/article/details/83688986
以 pip 安装后修改为例
-
修改 airflow.cfg
default_timezone = Asia/Shanghai
-
vi airflow/utils/timezone.py
# 在 utc = pendulum.timezone(‘UTC’) 这行(第27行)代码下添加 from airflow import configuration as conf try: tz = conf.get("core", "default_timezone") if tz == "system": utc = pendulum.local_timezone() else: utc = pendulum.timezone(tz) except Exception: pass # 修改utcnow()函数 (在第69行) # d = dt.datetime.utcnow() d = dt.datetime.now()
-
vi airflow/utils/sqlalchemy.py
# 在utc = pendulum.timezone(‘UTC’) 这行(第37行)代码下添加 from airflow import configuration as conf try: tz = conf.get("core", "default_timezone") if tz == "system": utc = pendulum.local_timezone() else: utc = pendulum.timezone(tz) except Exception: pass
-
vi airflow/www/templates/admin/master.html
<!-- 第31行 --> <!-- var UTCseconds = (x.getTime() + x.getTimezoneOffset()*60*1000); --> var UTCseconds = x.getTime(); <!-- "timeFormat":"H:i:s %UTC%", --> "timeFormat":"H:i:s",
-
重启 airflow-webserver
# 没有配置 systemd 使用其它方式 systemctl restart airflow-webserver