mhenc commented on code in PR #30308:
URL: https://github.com/apache/airflow/pull/30308#discussion_r1154340124
##########
airflow/jobs/base_job.py:
##########
@@ -175,10 +155,6 @@ def kill(self, session=None):
def on_kill(self):
"""Will be called when an external kill command is received."""
- @provide_session
- def heartbeat_callback(self, session=None) -> None:
- """Callback that is called during heartbeat. This method should be
overwritten."""
-
def heartbeat(self, only_if_necessary: bool = False):
Review Comment:
AFAIU this method will be executed only throught "perform_heartbeat" static
method.
Shouldn't we make it (and maybe some other) private?
##########
airflow/jobs/pydantic/base_job.py:
##########
@@ -32,13 +37,34 @@ class BaseJobPydantic(BaseModelPydantic):
job_type: Optional[str]
start_date: Optional[datetime]
end_date: Optional[datetime]
- latest_heartbeat: Optional[datetime]
+ latest_heartbeat: datetime
executor_class: Optional[str]
hostname: Optional[str]
unixname: Optional[str]
- task_instance: TaskInstancePydantic
+
+ # not an ORM field
+ heartrate: Optional[int]
class Config:
"""Make sure it deals automatically with ORM classes of SQL Alchemy"""
orm_mode = True
+
+ @property
+ def job_runner(self) -> BaseJobRunner:
+ from airflow.cli.commands.dag_processor_command import
_dag_processor_job_runner
+ from airflow.cli.commands.task_command import _local_task_job_runner
+ from airflow.cli.commands.triggerer_command import
_triggerer_job_runner
+
+ if self.job_type == "LocalTaskJob":
+ return check_runner_initialized(_local_task_job_runner,
self.job_type)
+ elif self.job_type == "DagProcessorJob":
+ return check_runner_initialized(_dag_processor_job_runner,
self.job_type)
+ elif self.job_type == "TriggererJob":
+ return check_runner_initialized(_triggerer_job_runner,
self.job_type)
+ else:
+ raise ValueError(
+ f"The job_type: {self.job_type} is not suitable for running
without the DB."
+ f"It should never usse BaseJobPydantic to retrieve the runner
but should use BaseJob."
Review Comment:
usse - typo
--
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]