Airflow 1.10.1 - 更改时区
Airflow 1.10.1 - Change TimeZone
我通过 docker 在 GCP 上的虚拟机内 运行 气流 (1.10.1)。已经更改了我的 VM 和配置的本地时间 (airflow.cfg) 还设置了我所在国家/地区的 default_zone(美国/Sao_Paulo),但它仍然在主屏幕上以 UTC 时间继续,因此处理也在 UTC 中完成。你还能做点别的吗?
Support for time zones is enabled by default. Airflow stores datetime information in UTC internally and in the database. It allows you to run your DAGs with time zone dependent schedules. At the moment Airflow does not convert them to the end user’s time zone in the user interface. There it will always be displayed in UTC. Also templates used in Operators are not converted.
时区信息暴露,由DAG编写者进行相应处理.
作为给定答案的补充,我能够通过以下代码根据我在 DAG 中的时区更改执行:
import pendulum
default_args = {
'owner': 'airflow',
'start_date': pendulum.datetime(year=2019, month=7, day=26).astimezone('America/Sao_Paulo'),
'depends_on_past': False,
'email': ['airflow@airflow.com'],
'email_on_failure': False,
'email_on_retry': False,
'depends_on_past': False,
# If a task fails, retry it once after waiting
# at least 5 minutes
'retries': 1,
'retry_delay': timedelta(minutes=5),
'on_failure_callback': slack_msg
}
dag = DAG(
dag_id=nm_dag,
default_args=default_args,
schedule_interval='40 11 * * *',
dagrun_timeout=timedelta(minutes=60)
)
您可以通过在气流配置中的变量“AIRFLOW__CORE__DEFAULT_TIMEZONE”中设置正确的时区值来更改它运行 时间内的文件或环境变量。
我通过 docker 在 GCP 上的虚拟机内 运行 气流 (1.10.1)。已经更改了我的 VM 和配置的本地时间 (airflow.cfg) 还设置了我所在国家/地区的 default_zone(美国/Sao_Paulo),但它仍然在主屏幕上以 UTC 时间继续,因此处理也在 UTC 中完成。你还能做点别的吗?
Support for time zones is enabled by default. Airflow stores datetime information in UTC internally and in the database. It allows you to run your DAGs with time zone dependent schedules. At the moment Airflow does not convert them to the end user’s time zone in the user interface. There it will always be displayed in UTC. Also templates used in Operators are not converted.
时区信息暴露,由DAG编写者进行相应处理.
作为给定答案的补充,我能够通过以下代码根据我在 DAG 中的时区更改执行:
import pendulum
default_args = {
'owner': 'airflow',
'start_date': pendulum.datetime(year=2019, month=7, day=26).astimezone('America/Sao_Paulo'),
'depends_on_past': False,
'email': ['airflow@airflow.com'],
'email_on_failure': False,
'email_on_retry': False,
'depends_on_past': False,
# If a task fails, retry it once after waiting
# at least 5 minutes
'retries': 1,
'retry_delay': timedelta(minutes=5),
'on_failure_callback': slack_msg
}
dag = DAG(
dag_id=nm_dag,
default_args=default_args,
schedule_interval='40 11 * * *',
dagrun_timeout=timedelta(minutes=60)
)
您可以通过在气流配置中的变量“AIRFLOW__CORE__DEFAULT_TIMEZONE”中设置正确的时区值来更改它运行 时间内的文件或环境变量。