-
Notifications
You must be signed in to change notification settings - Fork 445
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
fix Function on Kubernetes for Python V2 progamming model #3676
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree company="Microsoft" |
@vrdmr / @gavin-aguiar Could you review this? |
ping @vrdmr @gavin-aguiar - thank you! |
@@ -233,6 +241,19 @@ private async Task<TriggersPayload> GetTriggersLocalFiles() | |||
}; | |||
} | |||
|
|||
private static bool IsWorkerIndexingEnabled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. Worker indexing is default now
@@ -220,7 +226,9 @@ private async Task<TriggersPayload> GetTriggersLocalFiles() | |||
} | |||
} | |||
|
|||
var functionsJsons = GlobalCoreToolsSettings.CurrentWorkerRuntime == WorkerRuntime.dotnetIsolated | |||
var useMetadata = GlobalCoreToolsSettings.CurrentWorkerRuntime == WorkerRuntime.dotnetIsolated || IsWorkerIndexingEnabled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we checking for dotnet isolated?
{ | ||
var functionAppPath = Path.Combine(functionsPath, "function_app.py"); | ||
|
||
var functionAppContents = await File.ReadAllTextAsync(functionAppPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap I/O operations in try-catch blocks and log errors
{ | ||
{"type", $"httpTrigger"}, | ||
{"direction", "In"}, | ||
{"name", "req"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of repeated constants can go on top of the file for readability or a method can we created to better manage bindings for different triggerType..
private static List<Dictionary<string, object>> ParsePythonFunctionApp(string contents) | ||
{ | ||
var functionMetadataList = new List<Dictionary<string, object>>(); | ||
var functionPattern = new Regex(@"@app\.(\w+)(?:_trigger)?\(([^)]+)\)\s+def (\w+)\(", RegexOptions.Compiled | RegexOptions.Multiline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Add a comment explaining the what this regex does.
{"connection", properties["connection"]}, | ||
{"cardinality", "One"}, | ||
{"properties", new Dictionary<string, object> { { "supportsDeferredBinding", "True" } } } | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking: should you flatten the nested dictionary with an class (or an entity)?
}); | ||
break; | ||
// Add additional cases for other trigger types if necessary | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a new or unknown trigger type is encountered, it silently does nothing. This can cause hard-to-debug issues. IMHO extra logging will help here.
Issue describing the changes in this PR
Resolves python programming V2 does not work with function on kubernetes
Pull request checklist