This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new e928817f9a Remove implementation of `__eq__` method from DatasetEvent
(#25907)
e928817f9a is described below
commit e928817f9a4947c767ae962cfe7893c09bc0bd76
Author: Daniel Standish <[email protected]>
AuthorDate: Tue Aug 23 17:49:05 2022 -0700
Remove implementation of `__eq__` method from DatasetEvent (#25907)
---
airflow/models/dataset.py | 6 ------
tests/jobs/test_scheduler_job.py | 11 ++++++++++-
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/airflow/models/dataset.py b/airflow/models/dataset.py
index a91055e42d..1ab48ec9c9 100644
--- a/airflow/models/dataset.py
+++ b/airflow/models/dataset.py
@@ -308,12 +308,6 @@ class DatasetEvent(Base):
def uri(self):
return self.dataset.uri
- def __eq__(self, other) -> bool:
- if isinstance(other, self.__class__):
- return self.dataset_id == other.dataset_id and self.timestamp ==
other.timestamp
- else:
- return NotImplemented
-
def __repr__(self) -> str:
args = []
for attr in [
diff --git a/tests/jobs/test_scheduler_job.py b/tests/jobs/test_scheduler_job.py
index 3863a05b73..ff4c5bf698 100644
--- a/tests/jobs/test_scheduler_job.py
+++ b/tests/jobs/test_scheduler_job.py
@@ -3096,11 +3096,20 @@ class TestSchedulerJob:
with create_session() as session:
self.scheduler_job._create_dagruns_for_dags(session, session)
+ def dict_from_obj(obj):
+ """Get dict of column attrs from SqlAlchemy object."""
+ return {k.key: obj.__dict__.get(k) for k in
obj.__mapper__.column_attrs}
+
# dag3 should be triggered since it only depends on dataset1, and it's
been queued
created_run = session.query(DagRun).filter(DagRun.dag_id ==
dag3.dag_id).one()
assert created_run.state == State.QUEUED
assert created_run.start_date is None
- assert created_run.consumed_dataset_events == [event1, event2]
+
+ # we don't have __eq__ defined on DatasetEvent because... given the
fact that in the future
+ # we may register events from other systems, dataset_id + timestamp
might not be enough PK
+ assert list(map(dict_from_obj, created_run.consumed_dataset_events))
== list(
+ map(dict_from_obj, [event1, event2])
+ )
assert created_run.data_interval_start == DEFAULT_DATE +
timedelta(days=5)
assert created_run.data_interval_end == DEFAULT_DATE +
timedelta(days=11)
# dag2 DDRQ record should still be there since the dag run was *not*
triggered