ephraimbuddy commented on code in PR #39430:
URL: https://github.com/apache/airflow/pull/39430#discussion_r1609561575
##########
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:
Why remove this? Let's move it to the task_instances_enqueued. wdyt?
##########
airflow/__init__.py:
##########
@@ -81,6 +82,12 @@
# Deprecated lazy imports
"AirflowException": (".exceptions", "AirflowException", True),
}
+if TYPE_CHECKING:
+ # This is never executed, but tricks static analyzers (PyDev, PyCharm,)
+ # into knowing the types of these symbols, and what they contain.
+ from airflow.models.dag import DAG # noqa: TCH004
+ from airflow.models.dataset import Dataset # noqa: TCH004
+ from airflow.models.xcom_arg import XComArg # noqa: TCH004
Review Comment:
This should be done in a separate PR
##########
airflow/models/taskinstance.py:
##########
@@ -1367,6 +1367,11 @@ class TaskInstance(Base, LoggingMixin):
trigger = relationship("Trigger", uselist=False,
back_populates="task_instance")
triggerer_job = association_proxy("trigger", "triggerer_job")
+ queued_by_job = relationship(
+ "Job",
+ back_populates="task_instances_enqueued",
+ primaryjoin="Job.id == foreign(TaskInstance.queued_by_job_id)",
Review Comment:
I think we should have uselist=False since it was removed from backref at
the other end?
##########
airflow/providers_manager.py:
##########
@@ -51,6 +52,9 @@
else:
from importlib_resources import files as resource_files
+PS = ParamSpec("PS")
+RT = TypeVar("RT")
Review Comment:
I'm not ok with doing these typings in this PR
--
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]