Skip to content

Commit

Permalink
check isByRef
Browse files Browse the repository at this point in the history
if is byref OR is not formatted value


simplify condition


proxykernel should not remove targetkernel name
  • Loading branch information
colombod committed Jun 12, 2023
1 parent b0a9d3b commit ea9b1fc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
36 changes: 36 additions & 0 deletions src/Microsoft.DotNet.Interactive.Tests/KernelInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,42 @@ public async Task ProxyKernels_have_a_remote_uri()
.Be(new Uri("kernel://remote/python"));
}

[Fact] public async Task ProxyKernels_can_share_values()
{
using var localCompositeKernel = new CompositeKernel
{
(new CSharpKernel()).UseValueSharing()
};
using var remoteCompositeKernel = new CompositeKernel
{
(new FSharpKernel()).UseValueSharing()
};

ConnectHost.ConnectInProcessHost(
localCompositeKernel,
remoteCompositeKernel);

var proxyKernel = await localCompositeKernel
.Host
.ConnectProxyKernelOnDefaultConnectorAsync(
"fsharp",
new Uri("kernel://remote/fsharp"));

await remoteCompositeKernel.SendAsync(new SubmitCode("let x = 123"));

var result = await localCompositeKernel.SendAsync(new SubmitCode("""
#!set --name x --value @fsharp:x
x
""", targetKernelName:"csharp"));

result.Events.Should()
.ContainSingle<ReturnValueProduced>()
.Which
.Value
.Should()
.Be(123);
}

[Fact]
public async Task When_kernel_info_is_requested_from_proxy_then_ProxyKernel_kernel_info_is_updated()
{
Expand Down
8 changes: 0 additions & 8 deletions src/Microsoft.DotNet.Interactive/Connection/ProxyKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ private Task HandleByForwardingToRemoteAsync(KernelCommand command, KernelInvoca
}
}

var targetKernelName = command.TargetKernelName;
if (command.TargetKernelName == Name)
{
command.TargetKernelName = null;
}

var completionSource = new TaskCompletionSource<KernelEvent>();

var rootToken = KernelCommand.GetRootToken(token);
Expand All @@ -126,8 +120,6 @@ private Task HandleByForwardingToRemoteAsync(KernelCommand command, KernelInvoca

return completionSource.Task.ContinueWith(te =>
{
command.TargetKernelName = targetKernelName;
if (te.Result is CommandFailed cf)
{
context.Fail(command, cf.Exception, cf.Message);
Expand Down

0 comments on commit ea9b1fc

Please sign in to comment.