Coverage for /pythoncovmergedfiles/medio/medio/src/airflow/build/lib/airflow/utils/trigger_rule.py: 96%
24 statements
« prev ^ index » next coverage.py v7.0.1, created at 2022-12-25 06:11 +0000
« prev ^ index » next coverage.py v7.0.1, created at 2022-12-25 06:11 +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 ONE_SUCCESS = "one_success"
30 ONE_FAILED = "one_failed"
31 ONE_DONE = "one_done"
32 NONE_FAILED = "none_failed"
33 NONE_FAILED_OR_SKIPPED = "none_failed_or_skipped"
34 NONE_SKIPPED = "none_skipped"
35 DUMMY = "dummy"
36 ALWAYS = "always"
37 NONE_FAILED_MIN_ONE_SUCCESS = "none_failed_min_one_success"
38 ALL_SKIPPED = "all_skipped"
40 @classmethod
41 def is_valid(cls, trigger_rule: str) -> bool:
42 """Validates a trigger rule."""
43 return trigger_rule in cls.all_triggers()
45 @classmethod
46 def all_triggers(cls) -> set[str]:
47 """Returns all trigger rules."""
48 return set(cls.__members__.values())
50 def __str__(self) -> str:
51 return self.value