sunank200 commented on code in PR #46512:
URL: https://github.com/apache/airflow/pull/46512#discussion_r1948533602
##########
airflow/timetables/base.py:
##########
@@ -281,8 +282,17 @@ def generate_run_id(
self,
*,
run_type: DagRunType,
- logical_date: DateTime,
+ logical_date: DateTime | None,
data_interval: DataInterval | None,
+ run_after: DateTime = timezone.coerce_datetime(timezone.utcnow()),
Review Comment:
changed it now. Removed run_after from here completely. I will change this
after https://github.com/apache/airflow/pull/46398 is merged
##########
airflow/models/dag.py:
##########
@@ -1603,6 +1603,7 @@ def cli(self):
def test(
self,
logical_date: datetime | None = None,
+ run_after: datetime = timezone.utcnow(),
Review Comment:
changed it
##########
airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -354,18 +355,23 @@ def trigger_dag_run(
f"DAG with dag_id: '{dag_id}' has import errors and cannot be
triggered",
)
- logical_date = pendulum.instance(body.logical_date)
-
+ logical_date = pendulum.instance(body.logical_date) if body.logical_date
else None
+ run_after = timezone.coerce_datetime(timezone.utcnow())
Review Comment:
changed it.
##########
airflow/models/dag.py:
##########
@@ -2485,12 +2493,12 @@ def _get_or_create_dagrun(
*,
dag: DAG,
run_id: str,
- logical_date: datetime,
- data_interval: tuple[datetime, datetime],
+ logical_date: datetime | None,
+ data_interval: tuple[datetime, datetime] | None,
run_after: datetime,
conf: dict | None,
triggered_by: DagRunTriggeredByType,
- start_date: datetime,
+ start_date: datetime | None = None,
Review Comment:
changed it
##########
airflow/models/dagrun.py:
##########
@@ -621,10 +623,18 @@ def find_duplicate(cls, dag_id: str, run_id: str, *,
session: Session = NEW_SESS
return session.scalars(select(cls).where(cls.dag_id == dag_id,
cls.run_id == run_id)).one_or_none()
@staticmethod
- def generate_run_id(run_type: DagRunType, logical_date: datetime) -> str:
- """Generate Run ID based on Run Type and logical Date."""
+ def generate_run_id(
+ run_type: DagRunType, logical_date: datetime | None, run_after:
datetime = timezone.utcnow()
+ ) -> str:
Review Comment:
changed this
##########
airflow/api_connexion/schemas/dag_run_schema.py:
##########
@@ -78,17 +79,19 @@ class Meta:
@pre_load
def autogenerate(self, data, **kwargs):
- """Auto generate run_id and logical_date if they are not provided."""
- logical_date = data.get("logical_date", _MISSING)
+ """Auto generate run_id, logical_date and run_after if they are not
provided."""
+ run_after = data.get("run_after", _MISSING)
# Auto-generate logical_date if missing
- if logical_date is _MISSING:
- data["logical_date"] = str(timezone.utcnow())
+ if run_after is _MISSING:
+ data["run_after"] = str(timezone.utcnow())
Review Comment:
changed it
##########
airflow/models/dagrun.py:
##########
@@ -253,12 +253,14 @@ def __init__(
dag_version: DagVersion | None = None,
bundle_version: str | None = None,
):
+ # For manual runs where logical_date is None, ensure no data_interval
is set.
+ if logical_date is None:
+ data_interval = None
Review Comment:
Changed it.
--
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]