molcay commented on PR #37087:
URL: https://github.com/apache/airflow/pull/37087#issuecomment-1991817431

   @potiuk thank you for the detailed answer. Your suggestion makes sense 
totally. 
   
   I started to have a look what we can do and started to do some PoC. 
   Here is the summary of what is my mind:
   
   1. Add `triggered_by` field to `DagRun` model class.
   ```python
   triggered_by = Column(String(50))
   ```
   > The field will be **nullable** and will equal to `NULL`/`None` for 
scheduler managed dag runs. We only fill this field when the DAG run type is 
`MANUAL`
   
   2. Introduce a new enumeration for possible values for this field:
   ```python
   class DagRunTriggeredByType(str, enum.Enum):
       """Class with TriggeredBy types for DagRun"""
       CLI = 'cli'            # for the trigger subcommand for dag command in 
cli: airflow dags trigger
       OPERATOR = 'operator'  # for the TriggerDagRunOperator
       REST_API = 'rest_api'  # for triggering the DAG via RESTful API
       UI = 'UI'              # for clicking the `Trigger DAG` button
       TEST = 'TEST'          # for dag.test()
   
       def __str__(self):
           return self.value
   ```
   
   3. Use the enumeration in the related code
   
   After adding this feature, I think users can override the 
[`generated_run_id`](https://airflow.apache.org/docs/apache-airflow/stable/howto/timetable.html#changing-generated-run-id)
 and use the field to distinguish the DAG runs.
   
   WDYT?


-- 
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]

Reply via email to