You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "HumanIearning (via GitHub)" <gi...@apache.org> on 2024/06/18 10:18:45 UTC
[I] execution_date format [airflow]
HumanIearning opened a new issue, #40292:
URL: https://github.com/apache/airflow/issues/40292
### Apache Airflow version
2.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
execution date in dag task context is different from when dag is run by manually and scheduler
### when triggered
Marking 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 scheduled
Marking 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
but when print them
### when triggered
2024-06-18 10:07:49.528041+00:00
### when scheduled
2024-06-17 10:17:00+00:00
### What you think should happen instead?
both format should be same
### How to reproduce
```py
date_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 System
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)
### Versions of Apache Airflow Providers
apache-airflow-providers-celery==3.7.2
apache-airflow-providers-common-io==1.3.2
apache-airflow-providers-common-sql==1.14.0
apache-airflow-providers-fab==1.1.1
apache-airflow-providers-ftp==3.9.1
apache-airflow-providers-http==4.11.1
apache-airflow-providers-imap==3.6.1
apache-airflow-providers-smtp==1.7.1
apache-airflow-providers-sqlite==3.8.1
### Deployment
Docker-Compose
### Deployment details
use docker on mac
use `docker compose up`
### modified some env
\# image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.9.2}
build: .
### add env
AIRFLOW__CORE__DEFAULT_TIMEZONE: 'Asia/Seoul'
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] execution_date format [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 closed issue #40292: execution_date format
URL: https://github.com/apache/airflow/issues/40292
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] execution_date format [airflow]
Posted by "raphaelauv (via GitHub)" <gi...@apache.org>.
raphaelauv commented on issue #40292:
URL: https://github.com/apache/airflow/issues/40292#issuecomment-2176325754
yes , you can convert it by
```python
from pendulum import DateTime
def cast_pendulum_date(date: DateTime) -> str:
return date.format("YYYY-MM-DD HH:mm:ss+00:00")
```
```python
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) }}",
},
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] execution_date format [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on issue #40292:
URL: https://github.com/apache/airflow/issues/40292#issuecomment-2176675271
It seems that @raphaelauv 's snippet could do the work if it's only a matter of formatting.
It doesn't seem like a bug, though.
Converting into a discussion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org