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

Re-raise ModuleNotFoundError unless for guessed task #8660

Conversation

johnjameswhitman
Copy link
Contributor

Description

We just merged #8632, which should propagate import-errors that originate outside of the importlib.import_module call. After reading through the code again today, I realized my change may swallow some other import errors that should fail.

I've updated the integration test with clearer cases, and modified celery.loaders.base.find_related_module so that it only returns none if the exact task-module being guessed is what caused the ModuleNotFoundError.

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3ba50e4) 87.34% compared to head (3a448c5) 87.34%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8660   +/-   ##
=======================================
  Coverage   87.34%   87.34%           
=======================================
  Files         148      148           
  Lines       18519    18519           
  Branches     3164     3164           
=======================================
  Hits        16176    16176           
  Misses       2059     2059           
  Partials      284      284           
Flag Coverage Δ
unittests 87.31% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@johnjameswhitman johnjameswhitman changed the title Johnjameswhitman/autodiscovery non task importerror fix Re-raise ModuleNotFoundError in find_related_module unless for guessed task Nov 22, 2023
@johnjameswhitman johnjameswhitman changed the title Re-raise ModuleNotFoundError in find_related_module unless for guessed task Re-raise ModuleNotFoundError unless for guessed task Nov 22, 2023
@auvipy auvipy added this to the 5.3.x milestone Nov 22, 2023
Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

except the unit test the Int tests seems good

@@ -271,7 +271,7 @@ def find_related_module(package, related_name):
except ModuleNotFoundError as e:
import_exc_name = getattr(e, 'name', None)
# If candidate does not exist, then return None.
if import_exc_name and module_name.startswith(import_exc_name):
if import_exc_name and module_name == import_exc_name:
Copy link
Member

Choose a reason for hiding this comment

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

should we adjust the unit tests as well? with this new change?

@auvipy auvipy merged commit 9bcc6a9 into celery:main Nov 22, 2023
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants