0

There is a way to get the google account name running the DAGs from the DAG definition? This will be very helpful to track which users was running the DAGs.

I'm only see :

unixname    --> always airflow
owner       --> fixed in the dag definition

Regards Eduardo

edduuar
  • 21
  • 4

1 Answers1

0

Possible as DAGs in Composer are essentially GCS objects. The GCS object GET API does tell you who uploads that object. So here's one possible way of getting owner info:

  1. Define a function user_lookup() in your DAG definition.
  2. The implementation of user_look() consists of the following steps: a) gets the current file path (e.g., os.path.basename(__file__)); b) based on how Composer GCS objects are mapped locally, determines the corresponding GCS object path (e.g., gs://{your-bucket}/object); c) reads GCS object details and returns object.owner.
  3. In your DAG definition, set owner=user_lookup().

Let us know whether the above works for you.

Feng Lu
  • 691
  • 5
  • 6