Skip to content

SettingsApi ModuleNotFoundError fix when extensions enabled #1305

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

Merged
merged 19 commits into from
Aug 25, 2023

Conversation

gavin-aguiar
Copy link
Contributor

Description

Updated the try_get_sdk method to avoid popping azure.functions from sys.modules.
This was causing ImportError: cannot import name 'SettingsApi'
Instead now we add python_packages to sys path and then import azure.functions so that we always get the sdk from the customers library.

Other changes:
Refactored dispatcher.py to improve logging.

Fixes #1304


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

@gavin-aguiar gavin-aguiar force-pushed the gaaguiar/testing_extensions branch from 6e21519 to 2bf3688 Compare August 17, 2023 21:21
@gavin-aguiar gavin-aguiar changed the title Gaaguiar/testing extensions SettingsApi ModuleNotFoundError fix when extensions enabled Aug 17, 2023
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #1305 (6bd4dc1) into dev (d4bdf7e) will decrease coverage by 52.86%.
The diff coverage is 30.76%.

❗ Current head 6bd4dc1 differs from pull request most recent head e449ff5. Consider uploading reports for the commit e449ff5 to get more accurate results

@@             Coverage Diff             @@
##              dev    #1305       +/-   ##
===========================================
- Coverage   85.00%   32.15%   -52.86%     
===========================================
  Files          34       34               
  Lines        1914     1922        +8     
  Branches      363      366        +3     
===========================================
- Hits         1627      618     -1009     
- Misses        221     1303     +1082     
+ Partials       66        1       -65     
Flag Coverage Δ
unittests 32.15% <30.76%> (-52.80%) ⬇️

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

Files Changed Coverage Δ
azure_functions_worker/dispatcher.py 19.04% <0.00%> (-69.31%) ⬇️
azure_functions_worker/extension.py 44.95% <ø> (-54.13%) ⬇️
azure_functions_worker/loader.py 31.37% <ø> (-56.25%) ⬇️
azure_functions_worker/logging.py 33.33% <ø> (-13.84%) ⬇️
azure_functions_worker/utils/common.py 32.07% <20.00%> (-67.93%) ⬇️
azure_functions_worker/utils/dependency.py 33.08% <80.00%> (-56.40%) ⬇️
azure_functions_worker/constants.py 100.00% <100.00%> (ø)

... and 17 files with indirect coverage changes

})
req = Request('GET', f'{ctrl.url}/api/HttpTrigger1')
resp = ctrl.send_request(req)

self.assertEqual(resp.status_code, 200)
self.assertIn("Func Version: 1.11.1", resp.text)

@skipIf(sys.version_info.minor != 10,
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 want the same for 3.9? and see what the experience is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed. It should have the same behavior since extensions is enabled in this test.

@gavin-aguiar gavin-aguiar merged commit b689413 into dev Aug 25, 2023
@gavin-aguiar gavin-aguiar deleted the gaaguiar/testing_extensions branch August 25, 2023 20:58
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.

Fix extensions code for py39 consumption
2 participants