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

Be verbose about failure to import airflow_local_settings #17195

Merged
merged 8 commits into from
Jul 26, 2021

Conversation

baryluk
Copy link
Contributor

@baryluk baryluk commented Jul 23, 2021

Currently, if the module exists, but has errors (for example syntax
error, or transitive import of module that does not exist),
the airflow scheduler will not show any error.

In my opinion ImportError of airflow_local_settings should
be a fatal error, but let it be a warning for now.


^ 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
Copy link

boring-cyborg bot commented Jul 23, 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

@potiuk
Copy link
Member

potiuk commented Jul 23, 2021

I also think it should be a fatal error. Anyone thinks otherwise?

@baryluk
Copy link
Contributor Author

baryluk commented Jul 23, 2021

Actually transitive imports might still be not handled correctly.

Let me address this by checking the ModuleNotFoundError.name field

@potiuk
Copy link
Member

potiuk commented Jul 23, 2021

Yeah. exactly - failure to import local_settings at all is OK. but if the import inside local_settings fails, this should be a fatal error.

airflow/settings.py 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.

Agree we should raise error but raise is better as it keeps location of the original exception.

airflow/settings.py Outdated Show resolved Hide resolved
airflow/settings.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.

Nice! Really useful to detect some hard-to-debug problems!

@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.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jul 23, 2021
@baryluk
Copy link
Contributor Author

baryluk commented Jul 23, 2021

Nice! Really useful to detect some hard-to-debug problems!

It did bite me of course, that is why I am suggesting this change. I replaced from airflow.contrib.kubernetes.pod import Pod with from airflow.kubernetes.pod import Pod blindly. And was surirpised that some spark kubernetes jobs could not find secrets that were provided in the pod_mutation_hook in the airflow_local_settings.py, with no logging of the issue at all. :D

@potiuk potiuk closed this Jul 25, 2021
@potiuk potiuk reopened this Jul 25, 2021
@potiuk
Copy link
Member

potiuk commented Jul 25, 2021

Closed/reopened to re-trigger the build

@potiuk
Copy link
Member

potiuk commented Jul 25, 2021

Some static checks and tests are failing @baryluk

@baryluk
Copy link
Contributor Author

baryluk commented Jul 26, 2021

Some static checks and tests are failing @baryluk

@potiuk should be fixed. can rerun CI.

@potiuk
Copy link
Member

potiuk commented Jul 26, 2021

We had main broken so the test failures are unrelated. Those main errors were fixed this morning - can you please rebase to latest main ?

baryluk and others added 6 commits July 26, 2021 17:11
Currently, if the module exists, but has errors (for example syntax
error, or transitive import of module that does not exist),
the airflow scheduler will not show any error.

In my opinion `ImportError` of `airflow_local_settings` should
be a fatal error, but let it be a warning for now.
A case of `airflow_local_settings.py` importing a module
that does not exist, will also throw `ModuleNotFoundError`,
but it should not be silently ignored.
`ModuleNotFoundError` is a subclass of `ImportError`, so must be handled first.
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
@baryluk
Copy link
Contributor Author

baryluk commented Jul 26, 2021

We had main broken so the test failures are unrelated. Those main errors were fixed this morning - can you please rebase to latest main ?

Rebased.

@potiuk
Copy link
Member

potiuk commented Jul 26, 2021

Still static check problems. I highly recommend installing pre-commit, it will fix those kind of problems for you automatically :)

@potiuk
Copy link
Member

potiuk commented Jul 26, 2021

And tests are still failing (this time settings tests, so you will need to fix it)

@potiuk
Copy link
Member

potiuk commented Jul 26, 2021

seems like transient errors only. Merging.

@potiuk potiuk merged commit 9504cb5 into apache:main Jul 26, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 26, 2021

Awesome work, congrats on your first merged pull request!

@baryluk
Copy link
Contributor Author

baryluk commented Jul 26, 2021

@potiuk Thanks for your patience and quick review!

@baryluk baryluk deleted the patch-1 branch July 26, 2021 18:40
nathadfield pushed a commit to king/airflow that referenced this pull request Jul 29, 2021
* Be verbose about failure to import airflow_local_settings

Currently, if the module exists, but has errors (for example syntax
error, or transitive import of module that does not exist),
the airflow scheduler will not show any error.

A case of `airflow_local_settings.py` importing a module
that does not exist, will also throw `ModuleNotFoundError`,
but it should not be silently ignored.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants