osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Template for Operator' Json Argument


I think you need to convert any non-str type into a string to render it in
the template, i.e., just str(foo).

https://github.com/apache/incubator-airflow/blob/1d3bb5470711a935b36b6a0ab4c7ec414d460d75/airflow/models.py#L2613

But in your template, if I understand correctly that you're building a JSON
object as a string you could render that particular field without quotes
wrapping it, so a JSON parser would detect it as an int, not a str.  Does
that make sense?

Can you share your code?

Best,
Taylor

On Sat, May 5, 2018 at 4:42 AM ramandumcs@xxxxxxxxx <ramandumcs@xxxxxxxxx>
wrote:

> Hi All,
>
> We have implemented a custom operator which is derived from baseOperator.
> Custom operator takes a JSON argument. Some fields of this Json are string
> and others are integer. We need to templatised the string fields only and
> not integer. But on doing this we are getting the error
> airflow.exceptions.AirflowException: Type '<type 'int'>' used for parameter
> 'json[number]' is not supported for templating.
>
> So is this possible to have both string and integer in templatised field.
>
> Thanks,
> Raman Gupta
>
-- 
*Taylor Edmiston*
Blog <http://blog.tedmiston.com> | Stack Overflow CV
<https://stackoverflow.com/story/taylor> | LinkedIn
<https://www.linkedin.com/in/tedmiston/> | AngelList
<https://angel.co/taylor>