dabla commented on code in PR #55068:
URL: https://github.com/apache/airflow/pull/55068#discussion_r2988274929
##########
airflow-core/src/airflow/triggers/base.py:
##########
@@ -66,14 +79,56 @@ class BaseTrigger(abc.ABC, LoggingMixin):
supports_triggerer_queue: bool = True
def __init__(self, **kwargs):
+ super().__init__()
# these values are set by triggerer when preparing to run the instance
# when run, they are injected into logger record.
- self.task_instance = None
+ self._task_instance = None
self.trigger_id = None
+ self.template_fields = ()
+ self.template_ext = ()
+ self.task_id = None
def _set_context(self, context):
"""Part of LoggingMixin and used mainly for configuration of task
logging; not used for triggers."""
- raise NotImplementedError
+ pass
Review Comment:
This is because now BaseTrigger also extends Templater, thus we must make
sure the super constructor get's called which in it's turn calls the
self._set_context method, hence why I had to change it:
```
class BaseTrigger(abc.ABC, Templater, LoggingMixin):
"""
Base class for all triggers.
A trigger has two contexts it can exist in:
- Inside an Operator, when it's passed to TaskDeferred
- Actively running in a trigger worker
We use the same class for both situations, and rely on all Trigger
classes
to be able to return the arguments (possible to encode with
Airflow-JSON) that will
let them be re-instantiated elsewhere.
"""
supports_triggerer_queue: bool = True
def __init__(self, **kwargs):
super().__init__()
# these values are set by triggerer when preparing to run the
instance
# when run, they are injected into logger record.
self._task_instance = None
self.trigger_id = None
self.template_fields = ()
self.template_ext = ()
self.task_id = None
```
--
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]