dheerajturaga opened a new pull request, #56193:
URL: https://github.com/apache/airflow/pull/56193
Enable tasks running in isolated environments to access the username
that triggered a DAG run without requiring direct database access.
Changes:
- Add triggering_user_name field to DagRunProtocol interface
- Update task-sdk DagRun data model to include triggering_user_name
- Update execution API DagRun model to include triggering_user_name
- Ensure field flows from database through API to task context
This allows developers to identify DAG run triggers from within task
code using the existing DagRunProtocol interface.
```python
def find_owner(dag_run: DagRunProtocol) -> str:
"""
Extract the owner information from the DAG run.
Args:
dag_run: The DAG run protocol object containing run information
Returns:
str: Information about who triggered the DAG run
"""
triggering_user = dag_run.triggering_user_name
if triggering_user:
return f"DAG was triggered by user: {triggering_user}"
else:
return "DAG was triggered automatically (no user specified)"
```
--
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]