Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/airflow/utils/trigger_rule.py: 96%
25 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18from __future__ import annotations
20from enum import Enum
23class TriggerRule(str, Enum):
24 """Class with task's trigger rules."""
26 ALL_SUCCESS = "all_success"
27 ALL_FAILED = "all_failed"
28 ALL_DONE = "all_done"
29 ALL_DONE_SETUP_SUCCESS = "all_done_setup_success"
30 ONE_SUCCESS = "one_success"
31 ONE_FAILED = "one_failed"
32 ONE_DONE = "one_done"
33 NONE_FAILED = "none_failed"
34 NONE_FAILED_OR_SKIPPED = "none_failed_or_skipped"
35 NONE_SKIPPED = "none_skipped"
36 DUMMY = "dummy"
37 ALWAYS = "always"
38 NONE_FAILED_MIN_ONE_SUCCESS = "none_failed_min_one_success"
39 ALL_SKIPPED = "all_skipped"
41 @classmethod
42 def is_valid(cls, trigger_rule: str) -> bool:
43 """Validates a trigger rule."""
44 return trigger_rule in cls.all_triggers()
46 @classmethod
47 def all_triggers(cls) -> set[str]:
48 """Returns all trigger rules."""
49 return set(cls.__members__.values())
51 def __str__(self) -> str:
52 return self.value