Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

Attribute error fix for retry policy #1322

Closed gavin-aguiar closed 9 months ago

gavin-aguiar commented 9 months ago

Description

With the current release, python worker was failing with the following error Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: Failure Exception: AttributeError: 'Function' object has no attribute 'get_settings_dict' Stack: File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py', line 345, in _handle__functions_metadata_request fx_metadata_results = self.index_functions(function_path) File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py', line 622, in index_functions fx_metadata_results = loader.process_indexed_function( File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py', line 109, in process_indexed_function retry_protos = build_retry_protos(indexed_function) File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py', line 69, in build_retry_protos retry = indexed_function.get_settings_dict(RETRY_POLICY)

This error is caused in dedicated due the python worker using the library that the customer brings in. To fix this error we check if the get_settings_api attribute exists and then proceed with retry policy else set retry policy to None

Fixes #


PR information

Quality of Code and Contribution Guidelines

codecov[bot] commented 9 months ago

Codecov Report

Merging #1322 (5371466) into dev (82b988e) will decrease coverage by 53.37%. The diff coverage is 21.05%.

:exclamation: Current head 5371466 differs from pull request most recent head 6e3d652. Consider uploading reports for the commit 6e3d652 to get more accurate results

@@             Coverage Diff             @@
##              dev    #1322       +/-   ##
===========================================
- Coverage   85.46%   32.09%   -53.37%     
===========================================
  Files          34       34               
  Lines        1926     1938       +12     
  Branches      366      366               
===========================================
- Hits         1646      622     -1024     
- Misses        209     1315     +1106     
+ Partials       71        1       -70     
Flag Coverage Δ
unittests 32.09% <21.05%> (-53.32%) :arrow_down:

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

Files Coverage Δ
azure_functions_worker/loader.py 31.57% <21.05%> (-55.68%) :arrow_down:

... and 23 files with indirect coverage changes