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 2021/06/23 10:06:25 UTC

[GitHub] [airflow] ecerulm opened a new issue #16613: InvalidTimezone exception if DAG's start_date timezone is "+00:00"

ecerulm opened a new issue #16613:
URL: https://github.com/apache/airflow/issues/16613


   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
   Don't worry if they're not all applicable; just try to include what you can :-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
   NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
   
   PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
   
   Please complete the next sections or the issue will be closed.
   These questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**: 2.0.2
   
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release):
   - **Kernel** (e.g. `uname -a`):
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   
   ```
   dag_start_date = pendulum.parse("2019-08-01T00:00:00.000+00:00")
   dag = DAG(dag_id='simple_dag', start_date=dag_start_date)
   serialized_dag = SerializedDAG.to_dict(dag)
   serialized_dag['dag']['timezone'] # '+00:00'
   dag = SerializedDAG.from_dict(serialized_dag) # raises InvalidTimezone exception
   
   Traceback (most recent call last):
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pendulum/tz/zoneinfo/reader.py", line 50, in read_for
       file_path = pytzdata.tz_path(timezone)
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pytzdata/__init__.py", line 74, in tz_path
       raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
   pytzdata.exceptions.TimezoneNotFound: Timezone +00:00 not found at /Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pytzdata/zoneinfo/+00:00
   During handling of the above exception, another exception occurred:
   Traceback (most recent call last):
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
       exec(code_obj, self.user_global_ns, self.user_ns)
     File "<ipython-input-115-6c89c12cbb11>", line 1, in <module>
       dag = SerializedDAG.from_dict(serialized_dag)
     File "/Users/rubelagu/git/airflow/airflow/serialization/serialized_objects.py", line 795, in from_dict
       return cls.deserialize_dag(serialized_obj['dag'])
     File "/Users/rubelagu/git/airflow/airflow/serialization/serialized_objects.py", line 722, in deserialize_dag
       v = cls._deserialize_timezone(v)
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pendulum/tz/__init__.py", line 37, in timezone
       tz = _Timezone(name, extended=extended)
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pendulum/tz/timezone.py", line 40, in __init__
       tz = read(name, extend=extended)
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pendulum/tz/zoneinfo/__init__.py", line 9, in read
       return Reader(extend=extend).read_for(name)
     File "/Users/rubelagu/.pyenv/versions/airflow-venv/lib/python3.8/site-packages/pendulum/tz/zoneinfo/reader.py", line 52, in read_for
       raise InvalidTimezone(timezone)
   pendulum.tz.zoneinfo.exceptions.InvalidTimezone: Invalid timezone "+00:00"
   
   ```
   
   
   
   
   **What you expected to happen**:
   
   <!-- What do you think went wrong? -->
   
   The DAG holds a reference to the DAG's `start_date.tzinfo` and it will serialize  as `+00:00` (this can be checked with `serialized_dag['dag']['timezone']`, then when it's time to deserialize that it will try to do `pendulum.timezone('+00:00`)` which raises a `InvalidTimezone` exception. 
   
   
   In principle I would expect to be able to provide any `datetime` as start_date , and `+00:00` is common. The serialization/deserialization will be used in normal airflow operation so that any DAG with that kind of start_date will give exceptions. 
   
   Probably the **`dag.timezone` should not be serialized at all** and it should be **reconstructed** at deserialization time from `start_date`.
   
   Refactor this [section of airflow/models/dag.py::DAG.__init__()](https://github.com/apache/airflow/blob/c2af5e3ca22eca7d4797b141520a97cf5e5cc879/airflow/models/dag.py#L304-L313) into a method that can be called from both `DAG.__init__` and `SerializedDAG.from_dict`. That way the problem of serialize/deserialize a pendulum.timezone would be avoided.
   
   
   
   
   **How to reproduce it**:
   <!---
   
   As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.
   
   If you are using kubernetes, please attempt to recreate the issue using minikube or kind.
   
   ## Install minikube/kind
   
   - Minikube https://minikube.sigs.k8s.io/docs/start/
   - Kind https://kind.sigs.k8s.io/docs/user/quick-start/
   
   If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action
   
   You can include images using the .md style of
   ![alt text](http://url/to/img.png)
   
   To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.
   
   --->
   
   
   **Anything else we need to know**:
   
   Related issue: #16551
   Related PR: #16599
   
   <!--
   
   How often does this problem occur? Once? Every time etc?
   
   Any relevant logs to include? Put them here in side a detail tag:
   <details><summary>x.log</summary> lots of stuff </details>
   
   -->
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] uranusjr closed issue #16613: InvalidTimezone exception if DAG's start_date timezone is "+00:00"

Posted by GitBox <gi...@apache.org>.
uranusjr closed issue #16613:
URL: https://github.com/apache/airflow/issues/16613


   


-- 
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] uranusjr commented on issue #16613: InvalidTimezone exception if DAG's start_date timezone is "+00:00"

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


   Yes, I believe so. `+00:00` is now always force-converted into `Timezone("UTC")`.


-- 
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] potiuk commented on issue #16613: InvalidTimezone exception if DAG's start_date timezone is "+00:00"

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


   @uranusjr  - I believe, looking at the code, that it has been fixed in https://github.com/apache/airflow/pull/17414 ? Am I right? 


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