Uh oh!
There was an error while loading. Please reload this page.
AIP-72: Allow retrieving Connection from Task Context - #45043
Conversation
f812f2f to
518f485CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
304140b to
01a36d2Compareeef7296 to
38c6565CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Added a minimal Connection user-facing object in Task SDK definition for use in the DAG file - Added logic to get Connections in the context. Fixed some bugs in the way related to Connection parsing/serializing!
38c6565 to
2937a0cCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
amoghrajesh
left a comment
There was a problem hiding this comment.
Some comments lying open, rest LGTM
part of apache#44481 - Added a minimal Connection user-facing object in Task SDK definition for use in the DAG file - Added logic to get Connections in the context. Fixed some bugs in the way related to Connection parsing/serializing! Now, we have following Connection related objects: - `ConnectionResponse` is auto-generated and tightly coupled with the API schema. - `ConnectionResult` is runtime-specific and meant for internal communication between Supervisor & Task Runner. - `Connection` class here is where the public-facing, user-relevant aspects are exposed, hiding internal details. **Next up**: - Same for XCom & Variable - Implementation of BaseHook.get_conn Tested it with a DAG: <img width="1711" alt="image" src="https://github.com/user-attachments/assets/14d28fb7-f6c5-4fbe-b226-46873af2d0f3" /> DAG: ```py from __future__ import annotations from airflow.models.baseoperator import BaseOperator from airflow.models.dag import dag class CustomOperator(BaseOperator): def execute(self, context): import os os.environ["AIRFLOW_CONN_AIRFLOW_DB"] = "sqlite:///home/airflow/airflow.db" task_id = context["task_instance"].task_id print(f"Hello World {task_id}!") print(context) print(context["conn"].airflow_db) assert context["conn"].airflow_db.conn_id == "airflow_db" @dag() def super_basic_run(): CustomOperator(task_id="hello") super_basic_run() ``` For case where a **connection is not found** <img width="1435" alt="image" src="https://github.com/user-attachments/assets/7c5e0cb4-6ed4-41aa-9a57-e5641adce954" />
part of #44481
Now, we have following Connection related objects:
ConnectionResponseis auto-generated and tightly coupled with the API schema.ConnectionResultis runtime-specific and meant for internal communication between Supervisor & Task Runner.Connectionclass here is where the public-facing, user-relevant aspects are exposed, hiding internal details.Next up:
Tested it with a DAG:
DAG:
For case where a connection is not found
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.