mhenc commented on a change in pull request #21731:
URL: https://github.com/apache/airflow/pull/21731#discussion_r816569110
##########
File path: airflow/callbacks/callback_requests.py
##########
@@ -64,6 +73,34 @@ def __init__(
self.simple_task_instance = simple_task_instance
self.is_failure_callback = is_failure_callback
+ def __eq__(self, other):
+ if isinstance(other, TaskCallbackRequest):
+ return (
+ self.simple_task_instance.__dict__ ==
other.simple_task_instance.__dict__
+ and self.full_filepath == other.full_filepath
+ and self.is_failure_callback == other.is_failure_callback
+ and self.msg == other.msg
+ )
+ return False
+
+ def to_json(self) -> str:
+ dict_obj = self.__dict__.copy()
+ dict_obj["simple_task_instance"] =
dict_obj["simple_task_instance"].__dict__
+ return json.dumps(dict_obj)
+
+ @classmethod
+ def from_json(cls, json_str: str):
+ from airflow.models.taskinstance import SimpleTaskInstance
+
+ json_object = json.loads(json_str)
+ simple_task_object =
SimpleTaskInstance.from_dict(obj_dict=json_object.get("simple_task_instance"))
+ return cls(
+ full_filepath=str(json_object["full_filepath"]),
+ simple_task_instance=simple_task_object,
+ is_failure_callback=json_object.get("is_failure_callback", None),
+ msg=json_object.get("msg", None),
+ )
Review comment:
Right, thank you!
--
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]