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-3207] option to stop task pushing result to xcom #4056

Merged
merged 2 commits into from Jan 11, 2019

Conversation

marengaz
Copy link
Contributor

@marengaz marengaz commented Oct 15, 2018

Make sure you have checked all steps below.

Jira

Description

  • Here are some details about my PR, including screenshots of any UI changes:
    BaseOperator should have an option to stop a task pushing the return value of execute() to xcom.
    the default should be to push (preserves backward compat)

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    test_save_result_to_xcom() tests the flag in false. previous tests already test the auto/true option

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added.

Code Quality

  • Passes flake8

@marengaz marengaz changed the title AIRFLOW-3207 option to stop task pushing result to xcom [AIRFLOW-3207] option to stop task pushing result to xcom Oct 15, 2018
@codecov-io
Copy link

codecov-io commented Oct 15, 2018

Codecov Report

Merging #4056 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4056      +/-   ##
==========================================
+ Coverage   78.12%   78.13%   +<.01%     
==========================================
  Files         202      202              
  Lines       16483    16484       +1     
==========================================
+ Hits        12878    12879       +1     
  Misses       3605     3605
Impacted Files Coverage Δ
airflow/models/__init__.py 92.68% <100%> (ø) ⬆️

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 7a6acbf...b3a2f5b. Read the comment docs.

@ashb
Copy link
Member

ashb commented Oct 16, 2018

See also Fokko's comment here #3981 (review) (you may have already)

I'd rather we used the same flag we already have elsewhere xcom_push, as that is what many of the other operators already use. Additionally we can remove this flag from any operators that set it and let them fallback to using this flag on BaseOperator.

You may need to co-ordinate with @itscaro on this change

@marengaz
Copy link
Contributor Author

cheers @ashb - i wasn't aware of this pr, or that there were operators that already had this function built in individually!
i will change save_result_to_xcom to xcom_push

@marengaz
Copy link
Contributor Author

@ashb - we cant use a flag BaseOperator.xcom_push because this conflicts with the method BaseOperator.xcom_push(). I'll change the flag to be BaseOperator.do_xcom_push. it's already like this in some operators

@marengaz marengaz force-pushed the save_result_to_xcom branch 2 times, most recently from 66acb99 to 82373ee Compare October 24, 2018 10:59
@marengaz
Copy link
Contributor Author

flake8 check is failing due to lines i haven't edited. please can we merge?

probs also worth considering adding W504 to the flake8 ignore list / doing a bulk correct?

@@ -2473,6 +2476,7 @@ def __init__(
run_as_user=None,
task_concurrency=None,
executor_config=None,
do_xcom_push=True,
Copy link

Choose a reason for hiding this comment

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

True by default?

Copy link
Member

Choose a reason for hiding this comment

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

Since this is a global flag, it should be true by default to not change the behaviour of all existing operators that push.

I think?

Copy link

@itscaro itscaro Oct 26, 2018

Choose a reason for hiding this comment

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

XCOM feature if not used should be disabled by default as in base operators, users should declare explicitly the use of XCOM so that database is not filled with useless data.

For backwards compatibility, contrib operators, which currently push to XCOM by default, should be updated to activate XCOM explicitly, doing this way, other contrib operators will keep the current behavior of not using XCOM.

Copy link
Contributor Author

@marengaz marengaz Oct 26, 2018

Choose a reason for hiding this comment

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

if i was rewriting airflow from scratch, i would agree with you @itscaro.
but in this instance, where airflow is looking to mature a bit, i agree with @ashb; we should preserve bw compat where possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @ashb. For backward compatibility, it should be true by default.

Copy link

@itscaro itscaro Oct 30, 2018

Choose a reason for hiding this comment

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

You can still make it backward compatible by adding True to the operators which have this behavior:

As what I tried to do in #3981

Or a branch over this PR: master...itscaro:do_xcom_push

There is no good to introduce this default behavior as True in the models

Copy link
Member

Choose a reason for hiding this comment

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

Airflow currently operates as If this value has True by default -- if I write a custom operator and return "foo" from it that will make it to XCom. This is the behaviour we need to keep.

Copy link

Choose a reason for hiding this comment

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

I missed the case about operators outside of this repository. We might start to make it defaults to False for operators in this repository, for other modules the default is True for backwards compatibility until a major version?

To have to disable XCOM in each operator call might be something not wanted.

Copy link
Contributor

Choose a reason for hiding this comment

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

@itscaro You could set it in the default_args then.

@stale
Copy link

stale bot commented Dec 20, 2018

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

@stale stale bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Dec 20, 2018
@stale stale bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Dec 23, 2018
@ron819
Copy link
Contributor

ron819 commented Jan 8, 2019

@itscaro What is the status of this PR?

@marengaz
Copy link
Contributor Author

marengaz commented Jan 9, 2019

@ron819 this and #4345 are ready to go, im just waiting for a committer to merge it!

@Fokko
Copy link
Contributor

Fokko commented Jan 11, 2019

@marengaz Thanks, merging to master!

@Fokko Fokko merged commit 657b986 into apache:master Jan 11, 2019
wmorris75 pushed a commit to modmed/incubator-airflow that referenced this pull request Jul 29, 2019
@marengaz marengaz deleted the save_result_to_xcom branch September 12, 2019 17:57
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