Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-6943] Fix utf-8 encodeed description in DAG in Python 2 #7567

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions airflow/models/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,18 @@ def access_control(self, value):
def description(self):
return self._description

@property
def description_unicode(self):
if six.PY2:
try:
# in Py2 when you parse python code which is UTF-8 encoded you get byte str
# description here - but it is actually UTF-8 encoded, so you need to decode
# it in order to be correctly converted to
return self._description.decode("utf-8")
except UnicodeDecodeError:
pass
return self._description

@property
def pickle_id(self):
return self._pickle_id
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h3 class="pull-left">
<span style='color:#AAA;'>SUBDAG: </span> <span> {{ dag.dag_id }}</span>
{% else %}
<input id="pause_resume" dag_id="{{ dag.dag_id }}" type="checkbox" {{ "checked" if not dag.is_paused else "" }} data-toggle="toggle" data-size="mini" method="post">
<span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span> <small class="text-muted"> {{ dag.description }} </small>
<span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span> <small class="text-muted"> {{ dag.description_unicode }} </small>
{% endif %}
{% if root %}
<span style='color:#AAA;'>ROOT: </span> <span> {{ root }}</span>
Expand Down
2 changes: 1 addition & 1 deletion airflow/www_rbac/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3 class="pull-left">
<span style='color:#AAA;'>SUBDAG: </span> <span> {{ dag.dag_id }}</span>
{% else %}
<input id="pause_resume" dag_id="{{ dag.dag_id }}" type="checkbox" {{ "checked" if not dag.is_paused else "" }} data-toggle="toggle" data-size="mini" method="post">
<span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span> <small class="text-muted"> {{ dag.description }} </small>
<span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span> <small class="text-muted"> {{ dag.description_unicode }} </small>
{% endif %}
{% if root %}
<span style='color:#AAA;'>ROOT: </span> <span> {{ root }}</span>
Expand Down