-
Notifications
You must be signed in to change notification settings - Fork 54
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
Enable external DF SDK #839
Conversation
...s/Microsoft.Azure.Functions.PowerShellWorker/Microsoft.Azure.Functions.PowerShellWorker.psm1
Outdated
Show resolved
Hide resolved
public Hashtable Invoke(OrchestrationBindingInfo orchestrationBindingInfo, IPowerShellServices pwsh) | ||
private IExternalOrchestrationInvoker externalInvoker; | ||
internal static string isOrchestrationFailureKey = "IsOrchestrationFailure"; | ||
|
||
public Hashtable Invoke( | ||
OrchestrationBindingInfo orchestrationBindingInfo, | ||
IPowerShellServices powerShellServices) | ||
{ | ||
try | ||
{ | ||
var outputBuffer = new PSDataCollection<object>(); | ||
var context = orchestrationBindingInfo.Context; | ||
if (powerShellServices.HasExternalDurableSDK()) |
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.
Unfortunately, the diff in this section of the code makes the edit seem more complicated than it is.
In short, the previous logic of the Invoke
method in here is now contained within the InvokeInternalDurableSDK
. However, for the rest of this file, the diff will show parts of the old method interleaved in weird ways with new methods.
pwsh.ClearStreamsAndCommands(); | ||
return null; |
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.
Just for clarity: the pwsh.ClearStreamsAndCommand()
call here didn't use to be in the CreateReturnValueFromFunctionOutput
method. The implementation of this method has not changed at all, it's just that the diff is acting up and still showing code from the previous Invoke
implementation.
@Francisco-Gamino: as per our last conversation, I've refactored the code so that it no longer imports the external Durable Functions SDK. Instead, this is now the responsibility of the user app to do that: they will have to run The main changes as of your latest review are in In This is all defined here:
DurableController leverages various changes in
|
PowerShellWorkerStrings.FoundExternalDurableSdkInSession, module.Name, module.Version, module.Path)); | ||
var externalSDKModuleInfo = string.Join('\n', candidatesInfo); | ||
|
||
if (numCandidates > 1) |
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.
Could you please add a test case that validates this logic?
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.
Discussed offline, sharing update:
The methods in PowerShellServices
aren't easy to test and given that this logic is behind a feature flag, we feel it should be safe to release as is. I have created this ticket to track the work of refactoring PowerShellServices
so that unit testing these methods is easier. Prior to GA'ing this work, we will need to have unit tests for these methods.
FYI @michaelpeng36
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.
I left a couple more comments. Thank you.
Thanks @Francisco-Gamino for your prompt reviews. I believe I have addressed all your comments except the unit test, to which I responded here: #839 (comment) No need to merge this at this point as it won't make a difference timeline wise, although it would be good to release this with the next worker release in early January. I also won't block if people want to merge this though :) . @Francisco-Gamino please let us know if this has your approval but I'm also happy to take on more feedback as this is an important feature. Thanks all. |
Hi @Francisco-Gamino, I think in our last conversation we deemed this PR ready to merge. Please let me know if that's still the case (or let me know if you have new suggestions :) ) so that we can keep the ball rolling here and merge promptly. Thanks! |
<value>The external Durable Functions SDK is enabled but it cannot be used because it was not loaded onto the current PowerShell session. Please add `Import-Module -Name {0} -ErrorAction Stop` to your profile.ps1 so it may be used. Defaulting to built-in SDK.</value> | ||
</data> | ||
<data name="MultipleExternalSDKsInSession" xml:space="preserve"> | ||
<value>Get-Module returned '{0}' instances of '{1}' in the PowerShell session, but only 1 or 0 are expected. This may create runtime errors. Please ensure your script only imports a single version of '{0}'. The modules currently in session are:\n '{2}'.</value> |
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.
Should we include the profile.ps1
file name in this line Please ensure your script only imports a single version of '{0}'
?
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.
Sure, I added an explicit reference to profile.ps1
in my latest commit: 8e0e103
Does that look good?
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.
I left one last minor comment. Otherwise, LGTM.
@davidmrdavid -- One more thing: As per our conversation, the DF SDK will need to be imported in the |
…n the profile.ps1 file
Thank you @Francisco-Gamino. Please let me know if my latest edit to the log message regarding having to import the module in |
FYI @Francisco-Gamino: As the CI has passed and as per our conversation, I'll go ahead and merge this! Thank you for all your help. |
This PR is the culmination of several smaller PRs that originated here: #746
This PR changes the Durable Functions logic in the worker to account for the possibility of an external Durable Functions SDK implementation. That SDK would be installed as a managed dependency, from the PowerShell Gallery.
If this external SDK were detected, we defer the invocation of orchestrator Function types to that external SDK. All other invocation types are still handled by the worker. In this refactoring, I've also simplified some of the orchestration-detection logic as shown in this PR's
InvokeFunction
method.This PR is in collaboration with @michaelpeng36
Pull request checklist
release_notes.md
Additional information
Before merging this PR, we will need to decide on the namespace of the new external Durable Functions SDK. In fact, it may be best to fully reserve it prior to merging.