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

[AIRFLOW-6392] Remove cyclic dependency baseoperator <-> helpers #6950

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Dec 29, 2019

There is a hidden cyclic dependency between baseoperator and helpers module.
It's hidden by local import but it is detected when baseoperator/helpers are
removed from pylint_todo.txt (and it's really there).

The dependency comes from BaseOperator using helpers and two helpers methods
(chain and cross_downstream) using BaseOperator. This can be solved by
converting the chain and cross_downstream methods to be static methods in
BaseOperator class.

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.
Read the Pull Request Guidelines for more information.

@codecov-io
Copy link

codecov-io commented Dec 29, 2019

Codecov Report

Merging #6950 into master will decrease coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6950      +/-   ##
==========================================
- Coverage   84.81%   84.53%   -0.29%     
==========================================
  Files         679      679              
  Lines       38495    38618     +123     
==========================================
- Hits        32649    32645       -4     
- Misses       5846     5973     +127
Impacted Files Coverage Δ
airflow/utils/helpers.py 81.69% <ø> (-1.06%) ⬇️
...low/example_dags/example_short_circuit_operator.py 100% <100%> (ø) ⬆️
airflow/models/baseoperator.py 96.25% <100%> (+0.17%) ⬆️
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/kubernetes/pod_launcher.py 45.25% <0%> (-46.72%) ⬇️
airflow/kubernetes/refresh_config.py 50.98% <0%> (-23.53%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 78.75% <0%> (-20%) ⬇️
airflow/contrib/operators/spark_submit_operator.py 90% <0%> (-2.86%) ⬇️
airflow/contrib/hooks/spark_submit_hook.py 83.06% <0%> (+0.98%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bfde02...2d5c38f. Read the comment docs.

@potiuk
Copy link
Member Author

potiuk commented Dec 29, 2019

I'd love some other review as well for that one, I am moving some of the "helper" methods to BaseOperator's static methods so it would be great to see if others have an opinion on that one :).

@potiuk
Copy link
Member Author

potiuk commented Dec 29, 2019

And we have a follow-up substantial pylint update on top of that, so it would be great to merge it rather quickly.

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

These functions are used by users, so we should think about backward compatibility.

@mik-laj
Copy link
Member

mik-laj commented Dec 29, 2019

CC: @zhongjiajie

@mik-laj
Copy link
Member

mik-laj commented Dec 29, 2019

Related PR:
#4779
e732006#comments

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

These functions are used by users, so we should think about backward compatibility.

@potiuk
Copy link
Member Author

potiuk commented Dec 30, 2019

These functions are used by users, so we should think about backward compatibility.

Yep. Agree - that's why i called others :)

@potiuk potiuk force-pushed the AIRFLOW-6392-remove-cyclic-dependency-baseoperator-helpers branch from 3456068 to c33cdaf Compare December 30, 2019 11:41
@potiuk
Copy link
Member Author

potiuk commented Dec 30, 2019

@mik-laj -> moved the methods back to be module methods (in baseoperator module) also added more description in UPDATING.

I would love to hear what others think about the need of keeping the backwards compatibility here. Seems that we can't agree with @mik-laj whether it's important or not in this case.

@potiuk potiuk force-pushed the AIRFLOW-6392-remove-cyclic-dependency-baseoperator-helpers branch 2 times, most recently from f531c8c to 2e803af Compare December 30, 2019 11:58
airflow/utils/helpers.py Outdated Show resolved Hide resolved
@@ -670,6 +672,7 @@ def __deepcopy__(self, memo):

for k, v in self.__dict__.items():
if k not in shallow_copy:
# noinspection PyArgumentList
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? I don't think we need this check. We can disable this check on our Pycharm/Intelij

Copy link
Member Author

Choose a reason for hiding this comment

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

I am afraid so. The check is super useful because it detects spelling mistakes in parameters or removed parameters.

This is actually a known problem because the memo parameter is by mistake missing in skeleton definition for python skeletons (from typeshed I believe). The issue is described
here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000181224-deepcopy-unexpected-memo-argument
and reported here (unresolved): https://youtrack.jetbrains.com/issue/PY-29664

I have not found a good way of silencing it only for deepcopy, so I propose we can leave it as it is.

UPDATING.md Outdated Show resolved Hide resolved
UPDATING.md Outdated Show resolved Hide resolved
UPDATING.md Outdated Show resolved Hide resolved
UPDATING.md Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the AIRFLOW-6392-remove-cyclic-dependency-baseoperator-helpers branch from 2e803af to 97a91b8 Compare December 30, 2019 15:26
@potiuk
Copy link
Member Author

potiuk commented Dec 30, 2019

Updated all comments @kaxil ! What shall we do with the backwards compatibility there? Do you think we should worry about this in this case?

@kaxil
Copy link
Member

kaxil commented Dec 30, 2019

Updated all comments @kaxil ! What shall we do with the backwards compatibility there? Do you think we should worry about this in this case?

#6950 (comment) - I think this one is still pending.

I think this is the chance to make it right so I won't worry much about backward-compatibility here.

We won't merge this into 1.10.*

@potiuk potiuk force-pushed the AIRFLOW-6392-remove-cyclic-dependency-baseoperator-helpers branch from 97a91b8 to 5594ddf Compare December 30, 2019 17:54
@potiuk
Copy link
Member Author

potiuk commented Dec 30, 2019

@mik-laj ?

@turbaszek
Copy link
Member

@potiuk can you rebase?

@zhongjiajie
Copy link
Member

These functions are used by users, so we should think about backward compatibility.

I submit #4779 due to use bit shift will so lengthy in some situation as I comment in #4779 (comment), but when I use chain could be more easy using chain(*[lists_of_task]), So IMO and situation, I think function chain is useful and I will not remove it, that my point

@zhongjiajie
Copy link
Member

Our community have another function chain big fans @bcb , FYI, chain import path will change in Ariflow 2.0

@zhongjiajie
Copy link
Member

zhongjiajie commented Dec 31, 2019

@potiuk Should we add remind user different import path in https://github.com/apache/airflow/blob/master/docs/concepts.rst#relationship-helper for different Airflow version? Besides, code looking good for me

@zhongjiajie
Copy link
Member

Updated all comments @kaxil ! What shall we do with the backwards compatibility there? Do you think we should worry about this in this case?

IMO, If only import path change but function still exists, I think is not a problem. But if remove function should be more careful.

There is a hidden cyclic dependency between baseoperator and helpers module.
It's hidden by local import but it is detected when baseoperator/helpers are
removed from pylint_todo.txt (and it's really there).

The dependency comes from BaseOperator using helpers and two helpers methods
(chain and cross_downstream) using BaseOperator. This can be solved by
converting the chain and cross_downstream methods to be static methods in
BaseOperator class.
@potiuk potiuk force-pushed the AIRFLOW-6392-remove-cyclic-dependency-baseoperator-helpers branch from 5594ddf to 2d5c38f Compare December 31, 2019 11:59
@potiuk
Copy link
Member Author

potiuk commented Dec 31, 2019

@zhongjiajie -> I added a note in concepts (and changed the name to "Relationship builders" :).

@turbaszek turbaszek merged commit e9e0203 into apache:master Dec 31, 2019
galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
…che#6950)

There is a hidden cyclic dependency between baseoperator and helpers module.
It's hidden by local import but it is detected when baseoperator/helpers are
removed from pylint_todo.txt (and it's really there).

The dependency comes from BaseOperator using helpers and two helpers methods
(chain and cross_downstream) using BaseOperator. This can be solved by
converting the chain and cross_downstream methods to be static methods in
BaseOperator class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants