potiuk commented on code in PR #34457:
URL: https://github.com/apache/airflow/pull/34457#discussion_r1438567596


##########
airflow/jobs/job.py:
##########
@@ -126,7 +127,19 @@ def executor(self):
     def heartrate(self) -> float:
         return Job._heartrate(self.job_type)
 
-    def is_alive(self, grace_multiplier=2.1) -> bool:
+    @cached_property
+    def health_check_threshold(self) -> int | float:
+        grace_multiplier: float = 2.1

Review Comment:
   I think it's not exactly the same. Here `grace_multiplier` is hard-coded 2.1 
but it can be overwritten in the `is_alive` method. Also this property is now 
duplicated in two places (Job and Job Pydantic)
   
   What should happen is - similarly to other ORM/Pydantic classes  this 
property/method should be chaned into a `@lru_cache`  decorated fundtion as the 
top level function in job (taking job_type, grace_multiplier and heartrate as 
parameter) and it should be called in both Job and Job Pydantic. Decorating it 
with `@lru_cache` will cache the config retrieval as appropriate.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to