Skip to content

Commit 37db895

Browse files
authored
Merge pull request #36 from airflow-laminar/tkp/hf2
Expose end condition check as attribute on operator
2 parents 01807fb + 7837eb2 commit 37db895

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

airflow_ha/operator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class HighAvailabilityOperator(PythonSensor):
2626
_fail_trigger_kwargs: Optional[Dict[str, Any]] = None
2727
_fail_trigger_kwargs_conf: str = "{}"
2828

29+
_check_end_conditions: Optional[Callable] = None
30+
2931
_runtime: Optional[timedelta] = None
3032
_endtime: Optional[time] = None
3133
_maxretrigger: Optional[int] = None
@@ -69,7 +71,7 @@ def __init__(
6971
self._fail_trigger_kwargs_conf = self._fail_trigger_kwargs.pop("conf", {})
7072

7173
# Function to check end conditions
72-
check_end_conditions = ( # noqa: E731
74+
self._check_end_conditions = ( # noqa: E731
7375
lambda task_id=kwargs.get("task_id"),
7476
runtime=self._runtime,
7577
endtime=self._endtime,
@@ -86,7 +88,7 @@ def __init__(
8688
)
8789

8890
# Function to control the sensor
89-
callable_wrapper = lambda python_callable=python_callable, check_end_conditions=check_end_conditions, **kwargs: _callable_wrapper( # noqa: E731
91+
callable_wrapper = lambda python_callable=python_callable, check_end_conditions=self._check_end_conditions, **kwargs: _callable_wrapper( # noqa: E731
9092
python_callable=python_callable, check_end_conditions=check_end_conditions, **kwargs
9193
)
9294

@@ -189,6 +191,10 @@ def retrigger_fail(self) -> TriggerDagRunOperator:
189191
def retrigger_pass(self) -> TriggerDagRunOperator:
190192
return self._retrigger_pass
191193

194+
@property
195+
def check_end_conditions(self) -> Callable:
196+
return self._check_end_conditions
197+
192198

193199
# Function to check end conditions
194200
def _check_end_conditions(task_id, runtime, endtime, maxretrigger, start_date_or_logical_date, **kwargs):

0 commit comments

Comments
 (0)