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

Wrong template field types for AWS operators #16808

Closed
pavelhlushchanka opened this issue Jul 5, 2021 · 6 comments
Closed

Wrong template field types for AWS operators #16808

pavelhlushchanka opened this issue Jul 5, 2021 · 6 comments
Labels
kind:bug This is a clearly a bug provider:amazon-aws AWS/Amazon - related issues

Comments

@pavelhlushchanka
Copy link
Contributor

Apache Airflow version: 2.1.1

Environment:

  • Cloud provider or hardware configuration: AWS

What happened:

After migrating from Airflow 2.0.1 to 2.1.1, the Rendered Template tab stopped working for dictionaries. I checked it for Sagemaker and ECS operators, the code is not shown.

However for some operators where i have customized list of template_fields, it partly works (only for extra fields).
Screenshot 2021-07-05 at 12 18 37

So then i checked a release notes and it looks like it's related to #15130 and for some AWS operators the type of the fields should be not py, but json since all those fields mostly simply propagated to boto3 as json.

@pavelhlushchanka pavelhlushchanka added the kind:bug This is a clearly a bug label Jul 5, 2021
@pavelhlushchanka
Copy link
Contributor Author

It might be not just for AWS operators, but these are the ones i use and i could test

@uranusjr
Copy link
Member

uranusjr commented Jul 5, 2021

Hi! Would you be interested in submitting a PR to fix this?

@pavelhlushchanka
Copy link
Contributor Author

@uranusjr i can make pr but only for the operators i use

@uranusjr
Copy link
Member

uranusjr commented Jul 5, 2021

That’s perfectly fine! If some other operators also have this issue, people who use them can submit fixes for them.

@jordanjeremy
Copy link
Contributor

jordanjeremy commented Jul 8, 2021

As mentioned previously, this is not specific to AWS operators. This issue also happens with @task decorated (TaskFlow API) operators, where the op_kwargs is a dict and is setup to be rendered as py.
image

Possible solution is to update the "get_python_source" in utils/code_utils.py to handle list and dict. Possibly something like:

    if isinstance(x, list):
        return [str(v) for v in x]

    if isinstance(x, dict):
        return {k: str(v) for k, v in x.items()}

The converting values to strings seems necessary in order to avoid errors when this is passed to the pygments lexer.
image

@kaxil
Copy link
Member

kaxil commented Jul 11, 2021

Closed by #16820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug This is a clearly a bug provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

No branches or pull requests

5 participants