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

Ensure attr is in scope for error message #1351

Merged
merged 1 commit into from
Apr 12, 2016
Merged
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: 6 additions & 6 deletions airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ def render_templates(self):
for attr in task.__class__.template_fields:
content = getattr(task, attr)
if content:
rendered_content = rt(content, jinja_context)
rendered_content = rt(attr, content, jinja_context)
setattr(task, attr, rendered_content)

def email_alert(self, exception, is_retry=False):
Expand Down Expand Up @@ -1809,7 +1809,7 @@ def __deepcopy__(self, memo):
result.user_defined_macros = self.user_defined_macros
return result

def render_template_from_field(self, content, context, jinja_env):
def render_template_from_field(self, attr, content, context, jinja_env):
'''
Renders a template from a field. If the field is a string, it will
simply render the string and return the result. If it is a collection or
Expand All @@ -1820,10 +1820,10 @@ def render_template_from_field(self, content, context, jinja_env):
if isinstance(content, six.string_types):
result = jinja_env.from_string(content).render(**context)
elif isinstance(content, (list, tuple)):
result = [rt(e, context) for e in content]
result = [rt(attr, e, context) for e in content]
elif isinstance(content, dict):
result = {
k: rt(v, context)
k: rt("{}[{}]".format(attr, k), v, context)
for k, v in list(content.items())}
else:
param_type = type(content)
Expand All @@ -1833,7 +1833,7 @@ def render_template_from_field(self, content, context, jinja_env):
raise AirflowException(msg)
return result

def render_template(self, content, context):
def render_template(self, attr, content, context):
'''
Renders a template either from a file or directly in a field, and returns
the rendered result.
Expand All @@ -1848,7 +1848,7 @@ def render_template(self, content, context):
any([content.endswith(ext) for ext in exts])):
return jinja_env.get_template(content).render(**context)
else:
return self.render_template_from_field(content, context, jinja_env)
return self.render_template_from_field(attr, content, context, jinja_env)

def prepare_template(self):
'''
Expand Down