79465968

Date: 2025-02-25 09:20:27
Score: 1.5
Natty:
Report link

To be correct in getting actual data who manualy triggered your dag:

with create_session() as session:
    results = session.query(Log).filter(
        Log.dag_id == "your_dag_id",
        Log.event == "trigger",
        Log.execution_date == "here should be execution date of dagrun"
    ).first()
print(results.owner)

If you want to use this code inside some PythonOperator function with context input, then solution will be:

with create_session() as session:
    results = session.query(Log).filter(
        Log.dag_id == context["dag_run"].dag_id,
        Log.event == "trigger",
        Log.execution_date == context["dag_run"].execution_date
    ).first()
if results:
    print(f'User who manualy started dagRun: {results.owner}')
else:
    print('No data from log')

When results will be None?

p.s. now i am looking for how to fetch info about who and from what dag_id has triggered my dag.

Reasons:
  • Blacklisted phrase (2): i am looking for
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
Posted by: Alexander Shapkin