execution_date format #40308
-
Apache Airflow version2.9.2 If "Other Airflow 2 version" selected, which one?No response What happened?I don't know exactly it's bug, but I think it's weird when triggeredMarking task as UP_FOR_RETRY. dag_id=crawling_dag, task_id=process_goods_info_html, run_id=manual__2024-06-18T10:07:49.528041+00:00, execution_date=20240618T100749, start_date=20240618T100751, end_date=20240618T100751 when scheduledMarking task as SUCCESS. dag_id=crawling_dag, task_id=process_goods_info_html, run_id=scheduled__2024-06-17T09:54:00+00:00, execution_date=20240617T095400, start_date=20240618T095402, end_date=20240618T095402 it looks that execution_date is same when triggered2024-06-18 10:07:49.528041+00:00 when scheduled2024-06-17 10:17:00+00:00 What you think should happen instead?both format should be same How to reproducedate_format = "%Y-%m-%d %H:%M:%S%z"
date = kwargs["execution_date"]
print(str(date))
date = datetime.datetime.strptime(str(date), date_format).date() Operating SystemPRETTY_NAME="Debian GNU/Linux 12 (bookworm) Versions of Apache Airflow Providersapache-airflow-providers-celery==3.7.2 DeploymentDocker-Compose Deployment detailsuse docker on mac modified some env# image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.9.2} add envAIRFLOW__CORE__DEFAULT_TIMEZONE: 'Asia/Seoul' Anything else?No response Are you willing to submit PR?
Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
yes , you can convert it by from pendulum import DateTime
def cast_pendulum_date(date: DateTime) -> str:
return date.format("YYYY-MM-DD HH:mm:ss+00:00") DAG(
...
user_defined_macros={
"cast_pendulum_date": cast_pendulum_date
}
)
...
PythonOperator(
task_id="XXXX",
python_callable=XXXX,
do_xcom_push=True,
op_kwargs={
"date": "{{ cast_pendulum_date(logical_date) }}",
},
)
|
Beta Was this translation helpful? Give feedback.
-
It seems that @raphaelauv 's snippet could do the work if it's only a matter of formatting. |
Beta Was this translation helpful? Give feedback.
yes , you can convert it by