Taragolis commented on code in PR #39430:
URL: https://github.com/apache/airflow/pull/39430#discussion_r1609762234


##########
airflow/jobs/job.py:
##########
@@ -101,24 +95,18 @@ class Job(Base, LoggingMixin):
         Index("idx_job_dag_id", dag_id),
     )
 
-    task_instances_enqueued = relationship(
+    task_instances_enqueued = relationship(  # Task Instances which have been 
enqueued by this Job.
         "TaskInstance",
+        back_populates="queued_by_job",
         primaryjoin="Job.id == foreign(TaskInstance.queued_by_job_id)",
-        backref=backref("queued_by_job", uselist=False),
     )
 
-    dag_runs = relationship(
+    dag_runs = relationship(  # Only makes sense for SchedulerJob and 
BackfillJob instances.
         "DagRun",
-        primaryjoin=lambda: Job.id == 
foreign(_resolve_dagrun_model().creating_job_id),
-        backref="creating_job",
+        back_populates="creating_job",
+        primaryjoin="Job.id == foreign(DagRun.creating_job_id)",
     )
 
-    """
-    TaskInstances which have been enqueued by this Job.
-
-    Only makes sense for SchedulerJob and BackfillJob instances.
-    """
-

Review Comment:
   IMHO 
   
   This construction looks more clear
   ```python
   primaryjoin="Job.id == foreign(DagRun.creating_job_id)"
   ```   
   
   Rather than this
   ```python
   primaryjoin=lambda: Job.id == 
foreign(_resolve_dagrun_model().creating_job_id)
   ```
           



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