-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to make it work with LocalRuntime
- Loading branch information
1 parent
70c3a29
commit df98ee0
Showing
12 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
dotnet/src/Experimental/Process.Abstractions/IKernelExternalProcessMessageChannelEmitter.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,13 +31,15 @@ internal class LocalStep : IKernelProcessMessageChannel | |
protected Dictionary<string, Dictionary<string, object?>?>? _initialInputs = []; | ||
protected Dictionary<string, List<KernelProcessEdge>> _outputEdges; | ||
|
||
internal readonly IExternalKernelProcessMessageChannel? _externalMessageChannel; | ||
|
||
/// <summary> | ||
/// Represents a step in a process that is running in-process. | ||
/// </summary> | ||
/// <param name="stepInfo">An instance of <see cref="KernelProcessStepInfo"/></param> | ||
/// <param name="kernel">Required. An instance of <see cref="Kernel"/>.</param> | ||
/// <param name="parentProcessId">Optional. The Id of the parent process if one exists.</param> | ||
public LocalStep(KernelProcessStepInfo stepInfo, Kernel kernel, string? parentProcessId = null) | ||
public LocalStep(KernelProcessStepInfo stepInfo, Kernel kernel, string? parentProcessId = null, IExternalKernelProcessMessageChannel? externalMessageChannel = null) | ||
Check failure on line 42 in dotnet/src/Experimental/Process.LocalRuntime/LocalStep.cs
|
||
{ | ||
Verify.NotNull(kernel, nameof(kernel)); | ||
Verify.NotNull(stepInfo, nameof(stepInfo)); | ||
|
@@ -58,6 +60,13 @@ public LocalStep(KernelProcessStepInfo stepInfo, Kernel kernel, string? parentPr | |
this._logger = this._kernel.LoggerFactory?.CreateLogger(this._stepInfo.InnerStepType) ?? new NullLogger<LocalStep>(); | ||
this._outputEdges = this._stepInfo.Edges.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToList()); | ||
this._eventNamespace = $"{this._stepInfo.State.Name}_{this._stepInfo.State.Id}"; | ||
|
||
this._externalMessageChannel = externalMessageChannel; | ||
} | ||
|
||
~LocalStep() | ||
{ | ||
this._externalMessageChannel?.Uninitialize().GetAwaiter().GetResult(); | ||
Check failure on line 69 in dotnet/src/Experimental/Process.LocalRuntime/LocalStep.cs
|
||
} | ||
|
||
/// <summary> | ||
|
@@ -231,6 +240,13 @@ internal virtual async Task HandleMessageAsync(ProcessMessage message) | |
/// <exception cref="KernelException"></exception> | ||
protected virtual async ValueTask InitializeStepAsync() | ||
{ | ||
if (this._externalMessageChannel != null) | ||
{ | ||
// initialize external message channel | ||
// TODO: in LocalRuntime need to ensure initialization only happens once | ||
await this._externalMessageChannel.Initialize().ConfigureAwait(false); | ||
} | ||
|
||
// Instantiate an instance of the inner step object | ||
KernelProcessStep stepInstance = (KernelProcessStep)ActivatorUtilities.CreateInstance(this._kernel.Services, this._stepInfo.InnerStepType); | ||
var kernelPlugin = KernelPluginFactory.CreateFromObject(stepInstance, pluginName: this._stepInfo.State.Name); | ||
|
@@ -242,7 +258,7 @@ protected virtual async ValueTask InitializeStepAsync() | |
} | ||
|
||
// Initialize the input channels | ||
this._initialInputs = this.FindInputChannels(this._functions, this._logger); | ||
this._initialInputs = this.FindInputChannels(this._functions, this._logger, this._externalMessageChannel); | ||
this._inputs = this._initialInputs.ToDictionary(kvp => kvp.Key, kvp => kvp.Value?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)); | ||
|
||
// Activate the step with user-defined state if needed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters