Skip to content

Conversation

@zbstof
Copy link
Contributor

@zbstof zbstof commented Oct 13, 2021

Currently keys stay unrendered which is confusing for the users and require workaround like explicitly using Variable.get, which is evaluated eagerly during dag rendering, leading to further need for workarounds.

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@zbstof zbstof requested review from XD-DENG, ashb and kaxil as code owners October 13, 2021 11:34
@potiuk
Copy link
Member

potiuk commented Oct 13, 2021

I wonder if it can have some unintended side effects, I cannot think of any, but maybe there was a reason it was implemented like that ?

In any case @zbstof - you will need to add test cases covering that

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have some test cases for that

@zbstof
Copy link
Contributor Author

zbstof commented Oct 13, 2021

Turns out there's already a test that dict keys are not rendered, added by @BasPH , but I think it was codifying existing behaviour, not enforcing a contract.
I fixed that test
Please clarify if you want me to add more test cases?

maybe there was a reason it was implemented like that ?

Given how dicts are just fancy list of 2-tuples, and we already handle explicit lists and tuples, I don't see why we shouldn't handle dictionary keys

@potiuk
Copy link
Member

potiuk commented Oct 13, 2021

Wel. The fact that there was a test for that indicates that there could be a reason. I cannot think of any as well, but It's better to check it. This is quite crucial part of the code, so I would not like to spoil something.

@BasPH, @kaxil - I'd love to hear your thoughts here. Maybe there is a good reason for not rendering the keys?

@BasPH
Copy link
Contributor

BasPH commented Oct 13, 2021

It wasn't me :) This was added a long time ago -> https://github.com/apache/airflow/pull/4292/files

Technically I don't see anything wrong with also templating the keys 👍

@potiuk
Copy link
Member

potiuk commented Oct 13, 2021

Static checks are failing - the other failing tests is irrelevant - flaky test that will be fixed by #18947

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Oct 14, 2021
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk
Copy link
Member

potiuk commented Oct 14, 2021

Works for me then - some static checks need to be fixed though (and I think we should hold-off with merging that until we release 2.2.1 as there are potential conflicts I think).

@zbstof
Copy link
Contributor Author

zbstof commented Oct 20, 2021

I've fixed static check, should I rebase to fix broken tests in Quarantined tests?

@uranusjr
Copy link
Member

That would be best (although I don't think it'd help; Quarantined failed due to the task being killed because it ran for too long, not any concrete test failures)

@eladkal eladkal added this to the Airflow 2.2.2 milestone Oct 29, 2021
Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change in behaviour for keys, can you add this change in UPDATING.md please?

@eladkal
Copy link
Contributor

eladkal commented Dec 19, 2021

@zbstof can you please address above comment and rebase?

@zbstof
Copy link
Contributor Author

zbstof commented Dec 20, 2021

@eladkal, @kaxil
I've added an entry in UPDATING.md, please check if it's good enough

@zbstof zbstof reopened this Dec 20, 2021
@zbstof zbstof requested a review from kaxil December 29, 2021 11:05
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Feb 13, 2022
@zbstof
Copy link
Contributor Author

zbstof commented Feb 13, 2022 via email

@github-actions github-actions bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Feb 14, 2022
@github-actions
Copy link

github-actions bot commented Apr 1, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@zbstof
Copy link
Contributor Author

zbstof commented Apr 12, 2022

Can some of you point me to the example of the flag that @potiuk suggested?

@potiuk
Copy link
Member

potiuk commented Apr 12, 2022

Can some of you point me to the example of the flag that @potiuk suggested?

Just a new config like all the other airflow configs described here: https://github.com/apache/airflow/blob/main/airflow/config_templates/config.yml

@potiuk
Copy link
Member

potiuk commented Apr 19, 2022

Any news there @zbystof ?

@zbstof
Copy link
Contributor Author

zbstof commented Apr 20, 2022

Something like this, please check. Although due to #22003, changes to UPDATING.md are lost
Now this functionality is hidden by a flag

@zbstof zbstof force-pushed the patch-4 branch 2 times, most recently from 328b24e to 4a3bcd4 Compare April 21, 2022 09:28
@ashb ashb modified the milestones: Airflow 2.3.0, Airflow 2.4.0 Apr 22, 2022
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 11, 2022
@eladkal eladkal removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 11, 2022
@potiuk
Copy link
Member

potiuk commented Jun 13, 2022

Conflicts need to be fixed - can you fix them please @zbstof ?

…equire workarounds like explicitly using `Variable.get`, which is evaluated eagerly during dag rendering, leading to further need for workarounds.
@zbstof
Copy link
Contributor Author

zbstof commented Jun 13, 2022

Fixed conflicts and rebased

@potiuk
Copy link
Member

potiuk commented Jun 19, 2022

But the tests are failing.

@eladkal
Copy link
Contributor

eladkal commented Jun 29, 2022

Tests are still failing

tests/models/test_baseoperator.py::TestBaseOperator::test_render_template_with_flag: AssertionError: assert {'key_2': 'ba... foo }}_1': 1} == {'key_2': 'ba...key_bar_1': 1}
  Omitting 1 identical items, use -vv to show
  Left contains 1 more item:
  {'key_{{ foo }}_1': 1}
  Right contains 1 more item:
  {'key_bar_1': 1}

@zbstof
Copy link
Contributor Author

zbstof commented Jul 9, 2022

I'm going to ask for a bit of help here - why my test does not mock flag value here? Or maybe I'm approaching the test in a completely wrong way?

@potiuk
Copy link
Member

potiuk commented Jul 12, 2022

Typical problem (been there done that) when you are not used to patching. See the "patching in the wrong place": https://alexmarandon.com/articles/python_mock_gotchas/

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full tests needed We need to run full set of tests for this PR to merge stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants