[
https://issues.apache.org/jira/browse/AIRFLOW-1508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16663562#comment-16663562
]
ASF GitHub Bot commented on AIRFLOW-1508:
-----------------------------------------
ashb closed pull request #4059: [AIRFLOW-1508] Add SKIPPED to task states.
URL: https://github.com/apache/incubator-airflow/pull/4059
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/models.py b/airflow/models.py
index 40c466c9d9..a144608ec6 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -4894,7 +4894,7 @@ def create(dag_id, session=None):
"""
# unfortunately sqlalchemy does not know upsert
qry = session.query(DagStat).filter(DagStat.dag_id == dag_id).all()
- states = [dag_stat.state for dag_stat in qry]
+ states = {dag_stat.state for dag_stat in qry}
for state in State.dag_states:
if state not in states:
try:
diff --git a/airflow/utils/state.py b/airflow/utils/state.py
index a351df07b9..b73aaa12a0 100644
--- a/airflow/utils/state.py
+++ b/airflow/utils/state.py
@@ -51,6 +51,7 @@ class State(object):
RUNNING,
FAILED,
UPSTREAM_FAILED,
+ SKIPPED,
UP_FOR_RETRY,
QUEUED,
NONE,
@@ -79,18 +80,14 @@ class State(object):
@classmethod
def color(cls, state):
- if state in cls.state_color:
- return cls.state_color[state]
- else:
- return 'white'
+ return cls.state_color.get(state, 'white')
@classmethod
def color_fg(cls, state):
color = cls.color(state)
if color in ['green', 'red']:
return 'white'
- else:
- return 'black'
+ return 'black'
@classmethod
def finished(cls):
diff --git a/airflow/www/views.py b/airflow/www/views.py
index f786baa0fe..00bd0cf9c4 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -570,17 +570,13 @@ def dag_stats(self, session=None):
for dag in dagbag.dags.values():
payload[dag.safe_dag_id] = []
for state in State.dag_states:
- try:
- count = data[dag.dag_id][state]
- except Exception:
- count = 0
- d = {
+ count = data.get(dag.dag_id, {}).get(state, 0)
+ payload[dag.safe_dag_id].append({
'state': state,
'count': count,
'dag_id': dag.dag_id,
'color': State.color(state)
- }
- payload[dag.safe_dag_id].append(d)
+ })
return wwwutils.json_response(payload)
@expose('/task_stats')
@@ -641,17 +637,13 @@ def task_stats(self, session=None):
for dag in dagbag.dags.values():
payload[dag.safe_dag_id] = []
for state in State.task_states:
- try:
- count = data[dag.dag_id][state]
- except Exception:
- count = 0
- d = {
+ count = data.get(dag.dag_id, {}).get(state, 0)
+ payload[dag.safe_dag_id].append({
'state': state,
'count': count,
'dag_id': dag.dag_id,
'color': State.color(state)
- }
- payload[dag.safe_dag_id].append(d)
+ })
return wwwutils.json_response(payload)
@expose('/code')
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 5b84eef6ea..8d0a8b0ea8 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -301,17 +301,13 @@ def dag_stats(self, session=None):
if 'all_dags' in filter_dag_ids or dag.dag_id in
filter_dag_ids:
payload[dag.safe_dag_id] = []
for state in State.dag_states:
- try:
- count = data[dag.dag_id][state]
- except Exception:
- count = 0
- d = {
+ count = data.get(dag.dag_id, {}).get(state, 0)
+ payload[dag.safe_dag_id].append({
'state': state,
'count': count,
'dag_id': dag.dag_id,
'color': State.color(state)
- }
- payload[dag.safe_dag_id].append(d)
+ })
return wwwutils.json_response(payload)
@expose('/task_stats')
@@ -379,17 +375,13 @@ def task_stats(self, session=None):
if 'all_dags' in filter_dag_ids or dag.dag_id in filter_dag_ids:
payload[dag.safe_dag_id] = []
for state in State.task_states:
- try:
- count = data[dag.dag_id][state]
- except Exception:
- count = 0
- d = {
+ count = data.get(dag.dag_id, {}).get(state, 0)
+ payload[dag.safe_dag_id].append({
'state': state,
'count': count,
'dag_id': dag.dag_id,
'color': State.color(state)
- }
- payload[dag.safe_dag_id].append(d)
+ })
return wwwutils.json_response(payload)
@expose('/code')
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Skipped state not part of State.task_states
> -------------------------------------------
>
> Key: AIRFLOW-1508
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1508
> Project: Apache Airflow
> Issue Type: Bug
> Reporter: Ace Haidrey
> Assignee: Ace Haidrey
> Priority: Major
> Fix For: 1.10.1
>
>
> In the airflow.state module,
> [State.task_state|https://github.com/apache/incubator-airflow/blob/master/airflow/utils/state.py#L44]
> doesn't include the {{SKIPPED}} state even though the {{TaskInstance}}
> object has it. I was wondering if this was on purpose or a bug. I would think
> it should be part of the task_state object since that makes sense and will
> help some of my workflows to not have to add this in manually.
> I'm not sure who the appropriate person to ask is so thinking I'll tag some
> people and get some feedback (hopefully that's okay)..
> CC [~criccomini] [~bolke] [~allisonwang]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)