You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/02/15 00:21:39 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #29516: AIP-44 Migrate BaseJob.run to Internal API

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


##########
airflow/jobs/base_job.py:
##########
@@ -245,32 +246,47 @@ def heartbeat(self, only_if_necessary: bool = False):
             # We didn't manage to heartbeat, so make sure that the timestamp isn't updated
             self.latest_heartbeat = previous_heartbeat
 
+    @staticmethod
+    @internal_api_call
+    @provide_session
+    def pre_execute(job: BaseJob, *, session: Session = NEW_SESSION) -> None:
+        """Update the database job entry before running the _execute() function."""
+        job.state = State.RUNNING
+        session.add(job)
+        session.commit()
+        make_transient(job)

Review Comment:
   I think there is a bigger problem here. BaseJob is an SQLAlchemy model and we are effectively trying to serialize it with internal_api call. This is not going to end well.
   
   I think this is one of those cases where we need to do it differently and refactor the code quite a bit deeper. 



-- 
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-unsubscribe@airflow.apache.org

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