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

Change logLevel as debug for XCOM returned value message #19378

Conversation

KennethanCeyer
Copy link
Contributor

@KennethanCeyer KennethanCeyer commented Nov 3, 2021

related: #18264


The current Airflow version (2.x.x) supports Custom XCom Backends. and It means that the data from XCom could be larger than we think. (e.g. over 100GB)

However, PythonOperator and LevelDBOperator will try to show all of those data from XCom as a log message. This issue can cause web issues such as breaking the web page (due to browser memory issue or rendering speed issue). and It also will make it difficult to see the other log message from the task.

This PR suggests changing the logLevel info to debug, Because XCom returned value can be treated `debug purpose

^ Add meaningful description above

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.

@boring-cyborg boring-cyborg bot added area:core-operators Operators, Sensors and hooks within Core Airflow area:providers provider:google Google (including GCP) related issues labels Nov 3, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 3, 2021

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

airflow/operators/python.py Outdated Show resolved Hide resolved
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 be more careful with removing the log entry for Python operator which many people can rely on so conditional printing is much better, also unnecesary str() in level operator needs to be removed.

I suggest to split this change into two - one for Python operator (which is part of airlfow core package) and second for level one (which is in the google provider).

@KennethanCeyer
Copy link
Contributor Author

@potiuk
Thanks for the quick comment.
The concern that this PR change will come as a side effect for many users seems valid.

I plan to do two things as follows.

  1. Revert level one.
  2. Rollback the logLevel debug to info of PythonOperator and Make a new optional parameter to control the display of the return_value log
    (default is True, It means display the return_value log)

@KennethanCeyer KennethanCeyer marked this pull request as draft November 3, 2021 08:20
@KennethanCeyer
Copy link
Contributor Author

switch this PR to Draft due to the necessity to correct the related documents and write test specifications.

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.

Just one NIT: for the dosctring (thinking about future self wondering why this parameter is here).

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

github-actions bot commented Nov 7, 2021

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.

@KennethanCeyer KennethanCeyer marked this pull request as ready for review November 11, 2021 03:46
airflow/operators/python.py Outdated Show resolved Hide resolved
@KennethanCeyer
Copy link
Contributor Author

KennethanCeyer commented Nov 12, 2021

One quick question!
If the user uses DecoratedOperator as shown below through TaskFlow API,
there seems to be no way to block XCom return value logs.

@task
def my_task(): # Guess it is `_PythonDecoratedOperator`
    # ... process
    return large_data


with DAG(...) as dag:
    data = my_task() # It will make a huge log messages on Airflow UI
    my_second_task(data)

so, I think additional work will be required in a separate PR for TaskFlow API users.
What do you think?
Below are the locations that appear to require further work.

def __init__(
self,
**kwargs,
) -> None:
kwargs_to_upstream = {
"python_callable": kwargs["python_callable"],
"op_args": kwargs["op_args"],
"op_kwargs": kwargs["op_kwargs"],
}
super().__init__(kwargs_to_upstream=kwargs_to_upstream, **kwargs)

@uranusjr
Copy link
Member

uranusjr commented Nov 12, 2021

Yes we should do something for this but separately. Maybe something like (just a random idea)

@task(..., log_return_value="DEBUG")
def my_task():
    ...
    return large_data

@KennethanCeyer
Copy link
Contributor Author

@uranusjr
I see.
For that work, I will proceed by making another PR in the future.

@eladkal eladkal added this to the Airflow 2.3.0 milestone Nov 17, 2021
@potiuk potiuk merged commit 3d9e455 into apache:main Nov 17, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 17, 2021

Awesome work, congrats on your first merged pull request!

@KennethanCeyer KennethanCeyer deleted the feature/change-log-level-for-xcom-returned-value branch November 18, 2021 03:11
@uranusjr
Copy link
Member

I split the task API change into another issue (referenced above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow area:providers full tests needed We need to run full set of tests for this PR to merge provider:google Google (including GCP) related issues type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants