amoghrajesh commented on code in PR #51153:
URL: https://github.com/apache/airflow/pull/51153#discussion_r2135794284
##########
airflow-core/src/airflow/example_dags/example_assets.py:
##########
@@ -50,6 +50,7 @@
automatically as they depend on assets that do not get updated or are not
produced by any scheduled tasks.
"""
+# [START asset_def]
Review Comment:
Its ok to move the marker to after "from future" imports
##########
devel-common/src/sphinx_exts/docs_build/spelling_checks.py:
##########
@@ -71,17 +71,17 @@ def __lt__(self, other):
line_no_b: int = other.line_no or 0
context_line_a: str = self.context_line or ""
context_line_b: str = other.context_line or ""
- left: tuple[Path, int, int, str, str] = (
+ left: tuple[Path, int, str, str, str] = (
Review Comment:
Why this change?
##########
task-sdk/docs/index.rst:
##########
@@ -0,0 +1,102 @@
+ .. 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.
+
+Apache Airflow Task SDK
+=================================
+
+:any:`DAG` is where to start. :any:`dag`
+
+The Apache Airflow Task SDK(Task SDK) provides python-native interfaces for
defining DAGs,
+executing tasks in isolated subprocesses and interacting with Airflow resources
+(e.g., Connections, Variables, XComs, Metrics, Logs, and OpenLineage events)
at runtime.
+It also includes core execution-time components to manage communication
between the worker
+and the Airflow scheduler/backend.
+
+This approach reduces boilerplate and keeps your DAG definitions concise and
readable.
+
+
+Installation
+------------
+To install the Task SDK, run:
+
+.. code-block:: bash
+
+ pip install apache-airflow-task-sdk
+
+Getting Started
+---------------
+Define a basic DAG and task in just a few lines of Python:
+
+.. literalinclude::
../../airflow-core/src/airflow/example_dags/example_simplest_dag.py
+ :language: python
+ :start-after: [START simplest_dag]
+ :end-before: [END simplest_dag]
+ :caption: Simplest DAG with :func:`@dag <airflow.sdk.dag>` and
:func:`@task <airflow.sdk.task>`
+
+Examples
+--------
+
+For more examples DAGs and patterns, see the :doc:`examples` page.
+
+Key Concepts
+------------
+Defining DAGs
+~~~~~~~~~~~~~
+Use ``@dag`` to convert a function into an Airflow DAG. All nested ``@task``
calls
+become part of the workflow.
+
+Decorators
+~~~~~~~~~~
+Simplify task definitions using decorators:
+
+- :func:`@task <airflow.sdk.task>` : define tasks.
+- :func:`@task_group <airflow.sdk.task_group>`: group related tasks into
logical units.
+- :func:`@setup <airflow.sdk.setup>` and :func:`@teardown
<airflow.sdk.teardown>`: define setup and teardown tasks for DAGs and
TaskGroups.
+
+Tasks and Operators
+~~~~~~~~~~~~~~~~~~~
+Wrap Python callables with :func:`@task <airflow.sdk.task>` to create tasks,
leverage dynamic task mapping with
+``.expand()``, and pass data via ``XComArg``. You can also create traditional
Operators
+(e.g., sensors) via classes imported from the SDK:
+
+ - **BaseOperator**, **Sensor**, **OperatorLink**, **Notifier**, **XComArg**,
etc.
+ (see the **api reference** section for details)
+
+Assets
+~~~~~~
+Model data as assets and emit them to downstream tasks with the SDK's asset
library under
+``airflow.sdk.definitions.asset``. You can use:
+
+- :func:`@asset <airflow.sdk.asset>`, :class:`~airflow.sdk.AssetAlias`, etc.
(see the **api reference** section below)
+
+
+Execution Time Components
+~~~~~~~~~~~~~~~~~~~~~~~~~
+At runtime, tasks run in an isolated subprocess managed by the SDK:
+
+ - **Supervisor** coordinates the worker's lifecycle.
+ - **TaskRunner** actually executes the user's task code.
+ - **Context** objects provide runtime metadata (e.g., connections,
variables).
+ (see the **Execution Time** section below for details)
Review Comment:
If we want to continue mentioning these, we should also mention SDK API
client
##########
airflow-core/docs/index.rst:
##########
@@ -32,6 +32,15 @@ Airflow workflows are defined entirely in Python. This
"workflows as code" appro
- **Extensible**: The Airflow framework includes a wide range of built-in
operators and can be extended to fit your needs.
- **Flexible**: Airflow leverages the `Jinja
<https://jinja.palletsprojects.com>`_ templating engine, allowing rich
customizations.
+.. _task-sdk-docs:
+
+Task SDK
+========
+
+For Airflow Task SDK (Airflow 3.x+), see the standalone reference & tutorial
site:
Review Comment:
```suggestion
For Airflow Task SDK, see the standalone reference & tutorial site:
```
No need for this as the docs are versioned
##########
dev/breeze/doc/03_developer_tasks.rst:
##########
@@ -224,6 +224,11 @@ short ``provider id`` (might be multiple of them).
breeze build-docs <provider id> <provider id>
+.. code-block:: bash
+
+ # To build documentation for Task SDK package
+ breeze build-docs task-sdk
Review Comment:
```suggestion
To build documentation for Task SDK package, use the below command
.. code-block:: bash
breeze build-docs task-sdk
```
##########
airflow-core/src/airflow/example_dags/example_asset_alias.py:
##########
@@ -34,6 +34,7 @@
import pendulum
+# [START example_asset_alias]
Review Comment:
Marker doesn't cover the pendulum import
##########
airflow-core/src/airflow/example_dags/example_dag_decorator.py:
##########
@@ -15,6 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+# [START dag_decorator_usage]
Review Comment:
nit: Move it after the from future import
##########
task-sdk/docs/api.rst:
##########
@@ -0,0 +1,130 @@
+ .. 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.
+
+airflow.sdk API Reference
+=========================
+
+This page documents the full public API exposed in Airflow 3.0+ via the Task
SDK python module.
Review Comment:
```suggestion
This page documents the full public API exposed in Airflow 3 and later via
the Task SDK python module.
```
##########
task-sdk/docs/api.rst:
##########
@@ -0,0 +1,130 @@
+ .. 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.
+
+airflow.sdk API Reference
+=========================
+
+This page documents the full public API exposed in Airflow 3.0+ via the Task
SDK python module.
+
+If something is not on this page it is best to assume that it is not part of
the public API and use of it is entirely at your own risk
+-- we won't go out of our way break usage of them, but we make no promises
either.
Review Comment:
```suggestion
-- we won't go out of our way and break usage of them, but we make no
promises either otherwise.
```
##########
task-sdk/docs/conf.py:
##########
@@ -0,0 +1,74 @@
+# Disable Flake8 because of all the sphinx imports
+#
+# 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 __future__ import annotations
+
+from pathlib import Path
+
+CONF_DIR = Path(__file__).parent.absolute()
+
+project = "Apache Airflow Task SDK"
+
+language = "en"
+locale_dirs: list[str] = []
+
+extensions = [
+ "sphinx.ext.autodoc",
+ "autoapi.extension",
+ "sphinx.ext.intersphinx",
+]
+
+autoapi_dirs = [CONF_DIR.joinpath("..", "src").resolve()]
+autoapi_root = "api"
+autoapi_ignore = [
+ "*/airflow/sdk/execution_time",
+ "*/airflow/sdk/api",
+ "*/_internal*",
+]
+autoapi_options = [
+ "undoc-members",
+ "members",
+ "imported-members",
+]
+autoapi_add_toctree_entry = False
+autoapi_generate_api_docs = False
+
+autodoc_typehints = "description"
+
+# Prefer pyi over py files if both are found
+autoapi_file_patterns = ["*.pyi", "*.py"]
+# autoapi_generate_api_docs = False
Review Comment:
Can we remove this?
##########
task-sdk/docs/index.rst:
##########
@@ -0,0 +1,102 @@
+ .. 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.
+
+Apache Airflow Task SDK
+=================================
+
+:any:`DAG` is where to start. :any:`dag`
+
+The Apache Airflow Task SDK(Task SDK) provides python-native interfaces for
defining DAGs,
+executing tasks in isolated subprocesses and interacting with Airflow resources
+(e.g., Connections, Variables, XComs, Metrics, Logs, and OpenLineage events)
at runtime.
+It also includes core execution-time components to manage communication
between the worker
+and the Airflow scheduler/backend.
+
+This approach reduces boilerplate and keeps your DAG definitions concise and
readable.
+
+
+Installation
+------------
+To install the Task SDK, run:
+
+.. code-block:: bash
+
+ pip install apache-airflow-task-sdk
+
+Getting Started
+---------------
+Define a basic DAG and task in just a few lines of Python:
+
+.. literalinclude::
../../airflow-core/src/airflow/example_dags/example_simplest_dag.py
+ :language: python
+ :start-after: [START simplest_dag]
+ :end-before: [END simplest_dag]
+ :caption: Simplest DAG with :func:`@dag <airflow.sdk.dag>` and
:func:`@task <airflow.sdk.task>`
Review Comment:
Is this a repetition from above?
##########
task-sdk/docs/spelling_wordlist.txt:
##########
@@ -0,0 +1,2057 @@
+aarch
Review Comment:
Do we need this big comprehensive list?
##########
task-sdk/docs/index.rst:
##########
@@ -0,0 +1,102 @@
+ .. 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.
+
+Apache Airflow Task SDK
+=================================
+
+:any:`DAG` is where to start. :any:`dag`
+
+The Apache Airflow Task SDK(Task SDK) provides python-native interfaces for
defining DAGs,
Review Comment:
```suggestion
The Apache Airflow Task SDK provides python-native interfaces for defining
DAGs,
```
##########
task-sdk/docs/index.rst:
##########
@@ -0,0 +1,102 @@
+ .. 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.
+
+Apache Airflow Task SDK
+=================================
+
+:any:`DAG` is where to start. :any:`dag`
+
+The Apache Airflow Task SDK(Task SDK) provides python-native interfaces for
defining DAGs,
+executing tasks in isolated subprocesses and interacting with Airflow resources
+(e.g., Connections, Variables, XComs, Metrics, Logs, and OpenLineage events)
at runtime.
+It also includes core execution-time components to manage communication
between the worker
+and the Airflow scheduler/backend.
+
+This approach reduces boilerplate and keeps your DAG definitions concise and
readable.
+
+
+Installation
+------------
+To install the Task SDK, run:
+
+.. code-block:: bash
+
+ pip install apache-airflow-task-sdk
+
+Getting Started
+---------------
+Define a basic DAG and task in just a few lines of Python:
+
+.. literalinclude::
../../airflow-core/src/airflow/example_dags/example_simplest_dag.py
+ :language: python
+ :start-after: [START simplest_dag]
+ :end-before: [END simplest_dag]
+ :caption: Simplest DAG with :func:`@dag <airflow.sdk.dag>` and
:func:`@task <airflow.sdk.task>`
+
+Examples
+--------
+
+For more examples DAGs and patterns, see the :doc:`examples` page.
+
+Key Concepts
+------------
+Defining DAGs
+~~~~~~~~~~~~~
+Use ``@dag`` to convert a function into an Airflow DAG. All nested ``@task``
calls
+become part of the workflow.
+
+Decorators
+~~~~~~~~~~
+Simplify task definitions using decorators:
+
+- :func:`@task <airflow.sdk.task>` : define tasks.
+- :func:`@task_group <airflow.sdk.task_group>`: group related tasks into
logical units.
+- :func:`@setup <airflow.sdk.setup>` and :func:`@teardown
<airflow.sdk.teardown>`: define setup and teardown tasks for DAGs and
TaskGroups.
+
+Tasks and Operators
+~~~~~~~~~~~~~~~~~~~
+Wrap Python callables with :func:`@task <airflow.sdk.task>` to create tasks,
leverage dynamic task mapping with
+``.expand()``, and pass data via ``XComArg``. You can also create traditional
Operators
+(e.g., sensors) via classes imported from the SDK:
+
+ - **BaseOperator**, **Sensor**, **OperatorLink**, **Notifier**, **XComArg**,
etc.
+ (see the **api reference** section for details)
+
+Assets
+~~~~~~
+Model data as assets and emit them to downstream tasks with the SDK's asset
library under
+``airflow.sdk.definitions.asset``. You can use:
+
+- :func:`@asset <airflow.sdk.asset>`, :class:`~airflow.sdk.AssetAlias`, etc.
(see the **api reference** section below)
+
+
+Execution Time Components
+~~~~~~~~~~~~~~~~~~~~~~~~~
+At runtime, tasks run in an isolated subprocess managed by the SDK:
+
+ - **Supervisor** coordinates the worker's lifecycle.
+ - **TaskRunner** actually executes the user's task code.
+ - **Context** objects provide runtime metadata (e.g., connections,
variables).
Review Comment:
```suggestion
- **Context** objects provide runtime metadata (e.g., dag run details,
connections, variables, etc).
```
##########
task-sdk/tests/test_public_api.py:
##########
@@ -0,0 +1,74 @@
+# 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 __future__ import annotations
Review Comment:
I do not know if task-sdk/tests is right for this. Maybe create a
`task-sdk/docs`
##########
task-sdk/docs/index.rst:
##########
@@ -0,0 +1,102 @@
+ .. 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.
+
+Apache Airflow Task SDK
+=================================
+
+:any:`DAG` is where to start. :any:`dag`
+
+The Apache Airflow Task SDK(Task SDK) provides python-native interfaces for
defining DAGs,
+executing tasks in isolated subprocesses and interacting with Airflow resources
+(e.g., Connections, Variables, XComs, Metrics, Logs, and OpenLineage events)
at runtime.
+It also includes core execution-time components to manage communication
between the worker
+and the Airflow scheduler/backend.
+
+This approach reduces boilerplate and keeps your DAG definitions concise and
readable.
+
+
+Installation
+------------
+To install the Task SDK, run:
+
+.. code-block:: bash
+
+ pip install apache-airflow-task-sdk
+
+Getting Started
+---------------
+Define a basic DAG and task in just a few lines of Python:
+
+.. literalinclude::
../../airflow-core/src/airflow/example_dags/example_simplest_dag.py
+ :language: python
+ :start-after: [START simplest_dag]
+ :end-before: [END simplest_dag]
+ :caption: Simplest DAG with :func:`@dag <airflow.sdk.dag>` and
:func:`@task <airflow.sdk.task>`
+
+Examples
+--------
+
+For more examples DAGs and patterns, see the :doc:`examples` page.
+
+Key Concepts
+------------
+Defining DAGs
+~~~~~~~~~~~~~
+Use ``@dag`` to convert a function into an Airflow DAG. All nested ``@task``
calls
+become part of the workflow.
+
+Decorators
+~~~~~~~~~~
+Simplify task definitions using decorators:
+
+- :func:`@task <airflow.sdk.task>` : define tasks.
+- :func:`@task_group <airflow.sdk.task_group>`: group related tasks into
logical units.
+- :func:`@setup <airflow.sdk.setup>` and :func:`@teardown
<airflow.sdk.teardown>`: define setup and teardown tasks for DAGs and
TaskGroups.
+
+Tasks and Operators
+~~~~~~~~~~~~~~~~~~~
+Wrap Python callables with :func:`@task <airflow.sdk.task>` to create tasks,
leverage dynamic task mapping with
+``.expand()``, and pass data via ``XComArg``. You can also create traditional
Operators
+(e.g., sensors) via classes imported from the SDK:
+
+ - **BaseOperator**, **Sensor**, **OperatorLink**, **Notifier**, **XComArg**,
etc.
+ (see the **api reference** section for details)
+
+Assets
+~~~~~~
+Model data as assets and emit them to downstream tasks with the SDK's asset
library under
+``airflow.sdk.definitions.asset``. You can use:
+
+- :func:`@asset <airflow.sdk.asset>`, :class:`~airflow.sdk.AssetAlias`, etc.
(see the **api reference** section below)
+
+
+Execution Time Components
+~~~~~~~~~~~~~~~~~~~~~~~~~
+At runtime, tasks run in an isolated subprocess managed by the SDK:
Review Comment:
```suggestion
At runtime, tasks run in an isolated subprocess managed by the SDK Supervisor
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]