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/03/11 20:50:29 UTC

[GitHub] [airflow] dimberman commented on a change in pull request #13479: Added taskgroup decorator

dimberman commented on a change in pull request #13479:
URL: https://github.com/apache/airflow/pull/13479#discussion_r592709957



##########
File path: airflow/example_dags/example_task_group_decorator.py
##########
@@ -0,0 +1,71 @@
+#
+# 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.
+
+"""Example DAG demonstrating the usage of the @taskgroup decorator."""
+
+from airflow.decorators import task, taskgroup
+from airflow.models.dag import DAG
+from airflow.utils.dates import days_ago
+
+
+# [START howto_task_group_decorator]
+# Creating Tasks
+@task
+def task_start():
+    """Dummy Task which is First Task of Dag """
+    return '[Task_start]'
+
+
+@task
+def task_1(value):
+    """ Dummy Task1"""
+    return f'[ Task1 {value} ]'
+
+
+@task
+def task_2(value):
+    """ Dummy Task2"""
+    return f'[ Task2 {value} ]'
+
+
+@task
+def task_3(value):
+    """ Dummy Task3"""
+    print(f'[ Task3 {value} ]')
+
+
+@task
+def task_end():
+    """ Dummy Task which is Last Task of Dag """
+    print('[ Task_End  ]')
+
+
+# Creating TaskGroups
+@taskgroup

Review comment:
       might be nicer to call it "@task_group" instead of "@taskgroup" since there's no capitalization

##########
File path: airflow/example_dags/example_task_group_decorator.py
##########
@@ -0,0 +1,71 @@
+#
+# 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.
+
+"""Example DAG demonstrating the usage of the @taskgroup decorator."""
+
+from airflow.decorators import task, taskgroup
+from airflow.models.dag import DAG
+from airflow.utils.dates import days_ago
+
+
+# [START howto_task_group_decorator]
+# Creating Tasks
+@task
+def task_start():
+    """Dummy Task which is First Task of Dag """
+    return '[Task_start]'
+
+
+@task
+def task_1(value):
+    """ Dummy Task1"""
+    return f'[ Task1 {value} ]'
+
+
+@task
+def task_2(value):
+    """ Dummy Task2"""
+    return f'[ Task2 {value} ]'
+
+
+@task
+def task_3(value):
+    """ Dummy Task3"""
+    print(f'[ Task3 {value} ]')
+
+
+@task
+def task_end():
+    """ Dummy Task which is Last Task of Dag """
+    print('[ Task_End  ]')
+
+
+# Creating TaskGroups
+@taskgroup
+def section_1(value):
+    """ TaskGroup for grouping related Tasks"""
+    return task_3(task_2(task_1(value)))

Review comment:
       Can you unwind this? I wound't want to encourage people to nest like this.




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