flaky-artist-57016
09/18/2024, 12:36 PMpants.toml
. We package our code as a PEX and zip-deploy to Azure. Our pex_binary
target looks like this:
resource(name="function-app-config", source="host.json")
pex_binary(
name="az-function",
output_path="az-function.zip",
dependencies=[
"//:function-app-config",
"my_function:AzureFunction",
],
tags=["package"],
)
The error reported by Azure:
Result: Failure Exception: FunctionLoadError: cannot load the my_function function: type of
event binding in function.json "eventGridTrigger" does not match its Python annotation "EventGridEvent"
Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py",
line 485, in _handle__function_load_request
self._functions.add_function( File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/functions.py",
line 392, in add_function input_types, output_types, _ = self.validate_function_params( File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/functions.py",
line 251, in validate_function_params raise FunctionLoadError( # azure truncated it here...
As I mentioned earlier we changed nothing in the code or the function configuration--just the Pants version. Reverting the Pants upgrade returned the AF to working order. The PEXes produced by each version contain slightly different files in the deps and bootstrap directories, but the root containing our source is identical. Have there been any changes to the way PEXes are structured that could be related?elegant-florist-94385
09/18/2024, 2:02 PMflaky-artist-57016
09/18/2024, 2:04 PMelegant-florist-94385
09/18/2024, 2:05 PMflaky-artist-57016
09/18/2024, 2:05 PMwide-midnight-78598
09/18/2024, 2:33 PMpants peek
for each version (you'll need to sort the output), then compare version to version.
Flagrant errors usually pop up pretty quick.wide-midnight-78598
09/18/2024, 2:34 PMflaky-artist-57016
09/18/2024, 2:38 PM.bootstrap
files.
I’ll take a look at peek this afternoon.flaky-artist-57016
09/18/2024, 2:43 PMfunction.json
match the docs exactly (see v1 programming model) and are unchanged. Quite confusing.wide-midnight-78598
09/18/2024, 2:46 PMpants peek
your repo to see if there are changes, and if any of those might be relevantflaky-artist-57016
09/19/2024, 1:33 AMpants peek
output for the target defining the Function App is the new goals
field.happy-kitchen-89482
09/20/2024, 2:01 AMflaky-artist-57016
09/20/2024, 3:38 AMpex_binary
using the target shown in my earlier comment and using az function
to zip deploy the PEX.
I built test PEXes containing the minimum code required for an event triggered Function (see example for v1 Python programming model here) with each version of Pants from 2.17-2.21 and zip deployed them to Azure Functions. The PEXes generated starting with v2.20 throw the above error when the Function is triggered. I’ve attached the PEXes in case they may be of use in investigating the cause. The v2.20 change log mentions some changes to the pex tool, but none seem like they should affect this use case. No deprecation warnings/messages were shown during this process.flaky-artist-57016
11/19/2024, 4:44 PMbroad-processor-92400
01/14/2025, 12:30 AMpython_aws_lambda_function
target outputs a zip containing both first-party and third-party code at the top level. The AWS-specific stuff is the name and some smarts around choosing the right version of platform-specific dependencies, so this might have to use "complete platforms". In particular, all the pex smarts/overhead are executed and evaporated at build time.
Is there a chance you've tried either of them?flaky-artist-57016
01/14/2025, 12:37 AMIs there a chance you’ve tried either of them?I haven’t yet. I’ll take a look.