Coverage for airflow/utils/state.py : 67%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
# -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #
""" Static class with task instance states constants and color method to avoid hardcoding. """
# scheduler
# set by the executor (t.b.d.) # LAUNCHED = "launched"
# set by a task
QUEUED: 'gray', RUNNING: 'lime', SUCCESS: 'green', SHUTDOWN: 'blue', FAILED: 'red', UP_FOR_RETRY: 'gold', UPSTREAM_FAILED: 'orange', SKIPPED: 'pink', REMOVED: 'lightgrey', SCHEDULED: 'white', }
def color(cls, state): if state in cls.state_color: return cls.state_color[state] else: return 'white'
def color_fg(cls, state): color = cls.color(state) if color in ['green', 'red']: return 'white' else: return 'black'
def runnable(cls): return [ cls.NONE, cls.FAILED, cls.UP_FOR_RETRY, cls.UPSTREAM_FAILED, cls.SKIPPED, cls.QUEUED, cls.SCHEDULED ]
def finished(cls): """ A list of states indicating that a task started and completed a run attempt. Note that the attempt could have resulted in failure or have been interrupted; in any case, it is no longer running. """ return [ cls.SUCCESS, cls.SHUTDOWN, cls.FAILED, cls.SKIPPED, ]
def unfinished(cls): """ A list of states indicating that a task either has not completed a run or has not even started. """ return [ cls.NONE, cls.SCHEDULED, cls.QUEUED, cls.RUNNING, cls.UP_FOR_RETRY ] |