From a0edc24dc2ba26a604437e44bd87718c8d3bd9d9 Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 19 Sep 2019 21:55:34 +0100 Subject: [PATCH] FIXED --- ...ly_contract_has_not_been_broken.approved.json | 2 +- ...ta_contract_has_not_been_broken.approved.json | 2 +- ...lt_contract_has_not_been_broken.approved.json | 2 +- ...ly_contract_has_not_been_broken.approved.json | 2 +- ...ta_contract_has_not_been_broken.approved.json | 2 +- .../MessageSender.cs | 2 +- Microsoft.DotNet.Interactive.Jupyter/Shell.cs | 16 ++++++++-------- .../.ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 ++++++ NotebookExamples/Untitled.ipynb | 6 ++++++ 9 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 NotebookExamples/.ipynb_checkpoints/Untitled-checkpoint.ipynb create mode 100644 NotebookExamples/Untitled.ipynb diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Complete_reply_contract_has_not_been_broken.approved.json b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Complete_reply_contract_has_not_been_broken.approved.json index 737f4258f..aa66a3ee8 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Complete_reply_contract_has_not_been_broken.approved.json +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Complete_reply_contract_has_not_been_broken.approved.json @@ -1,6 +1,6 @@ data: more: True data: b27e4588f37f9d106875a3de5082622d4475874432c1973c423c4c44690f9fd9 more: True data: {"msg_id":"00000000-0000-0000-0000-000000000000","username":"dotnet_kernel","session":"test session","date":"0001-01-01T00:00:00Z","msg_type":"complete_reply","version":"5.3"} more: True -data: null more: True +data: {} more: True data: {} more: True data: {"matches":["Write","WriteLine"],"cursor_start":0,"cursor_end":0,"metadata":{},"status":"ok"} more: False diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Display_data_contract_has_not_been_broken.approved.json b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Display_data_contract_has_not_been_broken.approved.json index 757f8fcbc..6285952d7 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Display_data_contract_has_not_been_broken.approved.json +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Display_data_contract_has_not_been_broken.approved.json @@ -1,6 +1,6 @@ data: more: True data: c5121da74f5ffb064d676a281b3d48f643c9b26f60929966870dc52572cb7912 more: True data: {"msg_id":"00000000-0000-0000-0000-000000000000","username":"dotnet_kernel","session":"test session","date":"0001-01-01T00:00:00Z","msg_type":"display_data","version":"5.3"} more: True -data: null more: True +data: {} more: True data: {} more: True data: {"data":{"text/html":"some result","text/plain":"some result"},"metadata":{},"transient":{"display_id":"none"}} more: False diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Execute_result_contract_has_not_been_broken.approved.json b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Execute_result_contract_has_not_been_broken.approved.json index 96952acdd..e7ff4ba87 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Execute_result_contract_has_not_been_broken.approved.json +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Execute_result_contract_has_not_been_broken.approved.json @@ -1,6 +1,6 @@ data: more: True data: 6e64ac95f5a15be7e5efa2a0361145e55c6341b921954889de2a5b0a83161ccf more: True data: {"msg_id":"00000000-0000-0000-0000-000000000000","username":"dotnet_kernel","session":"test session","date":"0001-01-01T00:00:00Z","msg_type":"execute_result","version":"5.3"} more: True -data: null more: True +data: {} more: True data: {} more: True data: {"data":{"text/html":"some result","text/plain":"some result"},"metadata":{},"transient":{"display_id":"none"},"execution_count":12} more: False diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.KernelInfoReply_contract_has_not_been_broken.approved.json b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.KernelInfoReply_contract_has_not_been_broken.approved.json index 4d51ed807..470dfe278 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.KernelInfoReply_contract_has_not_been_broken.approved.json +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.KernelInfoReply_contract_has_not_been_broken.approved.json @@ -1,6 +1,6 @@ data: more: True data: 5f5b73dad44a06065f04b1d1b0b4656083a8c7bcc7fbbb170663283dcf91da20 more: True data: {"msg_id":"00000000-0000-0000-0000-000000000000","username":"dotnet_kernel","session":"test session","date":"0001-01-01T00:00:00Z","msg_type":"kernel_info_reply","version":"5.3"} more: True -data: null more: True +data: {} more: True data: {} more: True data: {"protocol_version":"5.3","implementation":".NET","implementation_version":"0.0.3","language_info":{"name":"C#","version":"4.0.30319","mimetype":"text/x-csharp","file_extension":".cs","pygments_lexer":"c#"},"banner":null,"status":"ok","help_links":[]} more: False diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Update_data_contract_has_not_been_broken.approved.json b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Update_data_contract_has_not_been_broken.approved.json index ee9b88c85..38db43887 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Update_data_contract_has_not_been_broken.approved.json +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/JupyterMessageContractTests.Update_data_contract_has_not_been_broken.approved.json @@ -1,6 +1,6 @@ data: more: True data: 6622cc56c4ef7c59c1d81a2f7e81cbf6cdeeadaa78a5b17541be690ed04de665 more: True data: {"msg_id":"00000000-0000-0000-0000-000000000000","username":"dotnet_kernel","session":"test session","date":"0001-01-01T00:00:00Z","msg_type":"update_display_data","version":"5.3"} more: True -data: null more: True +data: {} more: True data: {} more: True data: {"data":{"text/html":"some result","text/plain":"some result"},"metadata":{},"transient":{"display_id":"none"}} more: False diff --git a/Microsoft.DotNet.Interactive.Jupyter/MessageSender.cs b/Microsoft.DotNet.Interactive.Jupyter/MessageSender.cs index fdddfcb20..81e94e74f 100644 --- a/Microsoft.DotNet.Interactive.Jupyter/MessageSender.cs +++ b/Microsoft.DotNet.Interactive.Jupyter/MessageSender.cs @@ -35,7 +35,7 @@ public bool Send(Message message) Send(Constants.DELIMITER, _socket); Send(hmac, _socket); Send(message.Header.ToJson(), _socket); - Send(message.ParentHeader.ToJson(), _socket); + Send((message.ParentHeader?? new object()).ToJson(), _socket); Send(message.MetaData.ToJson(), _socket); Send(message.Content.ToJson(), _socket, false); diff --git a/Microsoft.DotNet.Interactive.Jupyter/Shell.cs b/Microsoft.DotNet.Interactive.Jupyter/Shell.cs index 507443e6a..28a36ead0 100644 --- a/Microsoft.DotNet.Interactive.Jupyter/Shell.cs +++ b/Microsoft.DotNet.Interactive.Jupyter/Shell.cs @@ -81,25 +81,25 @@ public async Task StartAsync(CancellationToken cancellationToken) using (var activity = Log.OnEnterAndExit()) { - SetStarting(); + //SetStarting(); while (!cancellationToken.IsCancellationRequested) { var message = _shell.GetMessage(); activity.Info("Received: {message}", message.ToJson()); - SetBusy(); + SetBusy(message.Header); switch (message.Header.MessageType) { case JupyterMessageContentTypes.KernelInfoRequest: id = Encoding.Unicode.GetString(message.Identifiers[0].ToArray()); HandleKernelInfoRequest(message); - SetIdle(); + SetIdle(message.Header); break; case JupyterMessageContentTypes.KernelShutdownRequest: - SetIdle(); + SetIdle(message.Header); break; default: @@ -112,7 +112,7 @@ public async Task StartAsync(CancellationToken cancellationToken) await context.Done(); - SetIdle(); + SetIdle(message.Header); break; } @@ -120,11 +120,11 @@ public async Task StartAsync(CancellationToken cancellationToken) } - void SetBusy() => _ioPubSender.Send(Message.Create(new Status(StatusValues.Busy), identifiers:new []{Message.Topic("status", id)})); + void SetBusy(Header parentHeader) => _ioPubSender.Send(Message.Create(new Status(StatusValues.Busy), parentHeader: parentHeader, identifiers:new []{Message.Topic("status", id)})); - void SetIdle() => _ioPubSender.Send(Message.Create(new Status(StatusValues.Idle), identifiers: new[] { Message.Topic("status", id) })); + void SetIdle(Header parentHeader) => _ioPubSender.Send(Message.Create(new Status(StatusValues.Idle), parentHeader: parentHeader, identifiers: new[] { Message.Topic("status", id) })); - void SetStarting() => _ioPubSender.Send(Message.Create(new Status(StatusValues.Starting), identifiers: new[] { Message.Topic("status", id) })); + } } diff --git a/NotebookExamples/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/NotebookExamples/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 000000000..2fd64429b --- /dev/null +++ b/NotebookExamples/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/NotebookExamples/Untitled.ipynb b/NotebookExamples/Untitled.ipynb new file mode 100644 index 000000000..2fd64429b --- /dev/null +++ b/NotebookExamples/Untitled.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +}