uranusjr commented on code in PR #30308:
URL: https://github.com/apache/airflow/pull/30308#discussion_r1162442200


##########
airflow/jobs/job.py:
##########
@@ -222,34 +222,23 @@ def heartbeat(self, only_if_necessary: bool = False) -> 
None:
             # We didn't manage to heartbeat, so make sure that the timestamp 
isn't updated
             self.latest_heartbeat = previous_heartbeat
 
-    def run(self) -> int | None:
-        """Starts the job."""
+    @provide_session
+    def prepare_for_execution(self, session: Session = NEW_SESSION):

Review Comment:
   Since the method and many others in the `run_job` chain of calls are all 
internal-only and always share one single session, the `@provide_session` 
decorator is unnecessary and only open possibilities for mis-uses. This would 
be better IMO
   
   ```suggestion
       def prepare_for_execution(self, *, session: Session) -> None:
   ```
   
   Also it’d be a good idea to add `:meta private:` to all of these functions.



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