You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/02 09:02:56 UTC

[GitHub] [airflow] juneyoung opened a new issue, #28676: Unable to parse date type in DAG

juneyoung opened a new issue, #28676:
URL: https://github.com/apache/airflow/issues/28676

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### What happened
   
   I passed variable via web UI, than access with dag_run.conf.
   ValueError occurs when I strptime with passed value.
   I can get passed value if I do not try to parsing.
   
   ``` python
   from airflow import DAG
   import pendulum
   from pendulum import datetime
   from datetime import timedelta
   from airflow.models.param import Param
   
   
   with DAG(
       dag_id='test_dateparse',
       description='Date parse',
       schedule_interval=None,
       catchup=False,
       dagrun_timeout=timedelta(minutes=30),
       start_date=datetime(2022, 9, 1, tz="Asia/Seoul"),
       params={"hour": Param("2099123123", type='string')},
       tags=['report'],
   ) as dag:
       target_hour = "{{ dag_run.conf.hour }}" # ex)2023010215
       try:
           # datetime.strptime(str(target_hour), "%Y%m%d%H")
           pendulum.from_format(target_hour, "YYYYMMDDHH")
       except ValueError as x:
           # both case you recieve ValueError like below
           # error: String does not match format YYYYMMDDHH, when value is value: 2099123123, type: <class 'str'>
       ... 
   
   ```
   
   But it works well in IDE python console...
   ``` python
   test_val = '2023010215'
   pendulum.from_format(test_val, 'YYYYMMDDHH')
   # DateTime(2023, 1, 2, 15, 0, 0, tzinfo=Timezone('UTC'))
   datetime.datetime.strptime(test_val, '%Y%m%d%H')
   # datetime.datetime(2023, 1, 2, 15, 0)
   ```
   
   ### What you think should happen instead
   
   `datetime.datetime.strptime` or `pendulum.from_format` should work same as local execution.
   
   
   ### How to reproduce
   
   You can add OP's code and in UI, run with trigger with params like
   ``` javascript
   {
       "hour": "2022010215"
   }
   ```
   
   ### Operating System
   
   NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.3 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal
   
   ### Versions of Apache Airflow Providers
   
   airflow == 2.3.0
   pendulum == 2.1.2
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### 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


[GitHub] [airflow] juneyoung closed issue #28676: Unable to parse date type in DAG

Posted by GitBox <gi...@apache.org>.
juneyoung closed issue #28676: Unable to parse date type in DAG
URL: https://github.com/apache/airflow/issues/28676


-- 
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


[GitHub] [airflow] juneyoung commented on issue #28676: Unable to parse date type in DAG

Posted by GitBox <gi...@apache.org>.
juneyoung commented on issue #28676:
URL: https://github.com/apache/airflow/issues/28676#issuecomment-1368766804

   Sorry for my misunderstanding.
   I did not know about jinja template


-- 
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


[GitHub] [airflow] boring-cyborg[bot] commented on issue #28676: Unable to parse date type in DAG

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #28676:
URL: https://github.com/apache/airflow/issues/28676#issuecomment-1368754906

   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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