SameerMesiah97 commented on code in PR #64751:
URL: https://github.com/apache/airflow/pull/64751#discussion_r3221220227


##########
airflow-core/src/airflow/models/deadline_alert.py:
##########
@@ -50,13 +50,22 @@ class DeadlineAlert(Base):
     name: Mapped[str | None] = mapped_column(String(250), nullable=True)
     description: Mapped[str | None] = mapped_column(Text, nullable=True)
     reference: Mapped[dict] = mapped_column(JSON, nullable=False)
-    interval: Mapped[float] = mapped_column(Float, nullable=False)
+    interval: Mapped[dict] = mapped_column(JSON, nullable=False)
     callback_def: Mapped[dict] = mapped_column(JSON, nullable=False)
 
     def __repr__(self):
-        interval_seconds = int(self.interval)
 
-        if interval_seconds >= 3600:
+        interval_seconds = None
+
+        if isinstance(self.interval, (int, float)):
+            interval_seconds = int(self.interval)

Review Comment:
   > Is it? I still see `self.interval` here, have you confirmed that this 
works as written?
   
   I believe this will only apply to line 64 below as the condition will check 
that that self.interval is a timedelta object before applying `total_seconds`. 
Line 60-61 is for floats and integers that have not been converted to timedelta 
objects. 
   
   I have tested the following DAG shape with both timedelta and the new 
VariableInterval object and can verify that it is working as expected:
   
   ```
   def long_running_task ():
   
       print ("Starting long-running task")
       time.sleep (120)
       print ("Ending long-running task")
   
   
   with DAG(
       dag_id="deadline_alert_example",
       deadline=DeadlineAlert( 
           reference=DeadlineReference.DAGRUN_QUEUED_AT,
           interval= [VariableInterval (key = 'deadline_seconds') / timedelta 
(seconds = 60],
           # deadline_seconds is set to 60.
           callback=AsyncCallback(
               custom_alert_callback
           ),
       ),
   ):
       PythonOperator(task_id="long_running_task", 
                      python_callable= long_running_task)
   ```
   



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