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/04/02 22:58:23 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #15142: Add support for labelling DAG edges (WIP)

kaxil commented on a change in pull request #15142:
URL: https://github.com/apache/airflow/pull/15142#discussion_r606464589



##########
File path: airflow/models/edgemodifier.py
##########
@@ -0,0 +1,126 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Sequence, Union
+
+from airflow.models.taskmixin import TaskMixin
+
+
+class EdgeModifier(TaskMixin):

Review comment:
       It isn't a model so we should probably move it to some other place instead of inside `airflow.models` -- probably inside `airflow/models/baseoperator.py` where we also have `set_upstream` and `set_downstream`?

##########
File path: airflow/serialization/schema.json
##########
@@ -102,7 +102,8 @@
         "_task_group": {"anyOf": [
           { "type": "null" },
           { "$ref": "#/definitions/task_group" }
-        ]}
+        ]},
+        "edge_info": { "$ref": "#/definitions/dict" }

Review comment:
       Yea similar to how we only store `_downstream_task_ids` (not the `_upstream_task_ids`) for a task and we can set upstream for the other when de-serializing. We do that to keep the size of serialized blog as small as possible.
   
   
   
   https://github.com/apache/airflow/blob/8cc8d11fb87d0ad5b3b80907874f695a77533bfa/airflow/serialization/serialized_objects.py#L451-L452
   
   https://github.com/apache/airflow/blob/8cc8d11fb87d0ad5b3b80907874f695a77533bfa/airflow/serialization/serialized_objects.py#L666-L668
   
   https://github.com/apache/airflow/blob/8cc8d11fb87d0ad5b3b80907874f695a77533bfa/airflow/serialization/serialized_objects.py#L724-L727
   
   https://github.com/apache/airflow/blob/8cc8d11fb87d0ad5b3b80907874f695a77533bfa/airflow/models/baseoperator.py#L1365-L1370
   
   We pay the price of hardcoding it but it is worth it as we can save MBs (which would be transmitted to and from the database) when number of tasks is huge.
   
   

##########
File path: airflow/utils/types.py
##########
@@ -15,6 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 import enum
+from typing import Optional
+
+try:
+    from typing import TypedDict
+except ImportError:
+    # Remove this fallback once our minumum version is 3.8
+    from mypy_extensions import TypedDict

Review comment:
       ```suggestion
   from airflow.typing_compat import TypedDict
   ```




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