Yaron
Yaron

Reputation: 10450

Airflow how to read JSON Input Params which includes '-' in the middle of param using Jinja

I’m running my DAG with configuration JSON, which includes parameters which includes -, e.g. market-name When I’m trying to read it using the following Jinja template:

path_prefix = f"market={{{{ params.market-name }}}}/configuration"

I’m getting the following error:

jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'market'

It seems to me that Jinja doesn’t identify the full param name market-name but get the first part before the - which is market .

My questions:

  1. Does Jinja supports having - in the middle of a param (e.g. market-name) or should I avoid it from the beginning and use market_name instead?
  2. If Jinja doesn’t support having a - in the middle of a param
  1. Should I use {{ params.market-name }} instead of {{{{ params.market-name }}}}?

Upvotes: 0

Views: 867

Answers (1)

Elad Kalif
Elad Kalif

Reputation: 15979

This is not Airflow bug. I reported it in this issue and this is a problem coming from Jinja/Python.

I could have not find any official documentation in Jinja that explains it but several reports mention that Jinja uses python interpreter's identifiers (see this answer and this answer). It might be best to report this issue to Jinja add documentation about it.

You can just avoid using -.

Upvotes: 1

Related Questions