Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
d789c93
Update README.md
cgravill May 3, 2016
11406b4
Corrected handling of ZeroMQ identities.
May 5, 2016
8322f6f
Upgrading FSharp.Charting to latest version
ndalchau May 5, 2016
5da2eb6
manual merge of readme file
May 6, 2016
245760e
Merge branch 'fsprojects-master'
May 6, 2016
52a04ce
Merged with fsprojects jupyter
May 6, 2016
434ee40
Further merge from fsprojects/jupyter
May 6, 2016
2595f7c
fixed merge mistake
May 6, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ipython-profile/ipython_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
c = get_config()
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source https://www.nuget.org/api/v2

nuget FSharp.Compiler.Service 3.0.0 framework: >= net451
nuget FSharp.Core.Microsoft.Signed 3.1.1.1 framework: >= net45
nuget NetMQ 3.3.0.11
nuget NetMQ 3.3.3.1
nuget Newtonsoft.Json 5.0.8 framework: >= net45
nuget FSharp.Charting 0.90.5 framework: >= net45
nuget FAKE
Expand Down
4 changes: 3 additions & 1 deletion paket.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
NUGET
remote: https://www.nuget.org/api/v2
specs:
AsyncIO (0.1.18)
FAKE (4.23.6)
FSharp.Charting (0.90.5) - framework: >= net45
FSharp.Compiler.Service (3.0) - framework: >= net451
FSharp.Core.Microsoft.Signed (3.1.1.1) - framework: >= net45
NetMQ (3.3.0.11)
NetMQ (3.3.3.1)
AsyncIO (>= 0.1.18)
Newtonsoft.Json (5.0.8) - framework: >= net45
xunit (2.1) - framework: >= net451
xunit.assert (2.1)
Expand Down
31 changes: 30 additions & 1 deletion src/IfSharp.Kernel/IfSharp.Kernel.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@
</Target>
-->
<Import Project="..\..\.paket\paket.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<ItemGroup>
<Reference Include="AsyncIO">
<HintPath>..\..\packages\AsyncIO\lib\net35\AsyncIO.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<ItemGroup>
<Reference Include="AsyncIO">
<HintPath>..\..\packages\AsyncIO\lib\net40\AsyncIO.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<ItemGroup>
Expand All @@ -145,6 +165,15 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<ItemGroup>
<Reference Include="NetMQ">
<HintPath>..\..\packages\NetMQ\lib\net35\NetMQ.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<ItemGroup>
<Reference Include="NetMQ">
Expand All @@ -166,4 +195,4 @@
</ItemGroup>
</When>
</Choose>
</Project>
</Project>
82 changes: 55 additions & 27 deletions src/IfSharp.Kernel/Kernel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =

// startup 0mq stuff
let context = NetMQContext.Create()

// heartbeat
let hbSocket = context.CreateRequestSocket()
do hbSocket.Bind(String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.hb_port))

// shell
let shellSocket = context.CreateRouterSocket()
do shellSocket.Bind(String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.shell_port))
let hbSocket = context.CreateRouterSocket()
let hbSocketURL =String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.hb_port)
do hbSocket.Bind(hbSocketURL)

// control
let controlSocket = context.CreateRouterSocket()
do controlSocket.Bind(String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.control_port))
let controlSocketURL = String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.control_port)
do controlSocket.Bind(controlSocketURL)

// stdin
let stdinSocket = context.CreateRouterSocket()
do stdinSocket.Bind(String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.stdin_port))
let stdinSocketURL = String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.stdin_port)
do stdinSocket.Bind(stdinSocketURL)

// iopub
let ioSocket = context.CreatePublisherSocket()
do ioSocket.Bind(String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.iopub_port))
let ioSocketURL = String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.iopub_port)
do ioSocket.Bind(ioSocketURL)

// shell
let shellSocket = context.CreateRouterSocket()
let shellSocketURL =String.Format("{0}://{1}:{2}", connectionInformation.transport, connectionInformation.ip, connectionInformation.shell_port)
do shellSocket.Bind(shellSocketURL)

let data = new List<BinaryOutput>()
let payload = new List<Payload>()
Expand Down Expand Up @@ -96,21 +100,20 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
ignore (hmac.TransformFinalBlock(Array.zeroCreate 0, 0, 0))
BitConverter.ToString(hmac.Hash).Replace("-", "").ToLower()

let recvAll (socket: NetMQSocket) = socket.ReceiveMessages()
let recvAll (socket: NetMQSocket) = socket.ReceiveMultipartBytes()

/// Constructs an 'envelope' from the specified socket
let recvMessage (socket: NetMQSocket) =

// receive all parts of the message
let message =
recvAll (socket)
|> Seq.map decode
|> Seq.toArray
let message = (recvAll (socket)) |> Array.ofSeq
let asStrings = message |> Array.map decode

// find the delimiter between IDS and MSG
let idx = Array.IndexOf(message, "<IDS|MSG>")
let idx = Array.IndexOf(asStrings, "<IDS|MSG>")

let idents = message.[0..idx - 1]
let messageList = message.[idx + 1..message.Length - 1]
let messageList = asStrings.[idx + 1..message.Length - 1]

// detect a malformed message
if messageList.Length < 4 then failwith ("Malformed message")
Expand Down Expand Up @@ -172,7 +175,7 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
msg.Append(encode parent_header)
msg.Append(encode "{}")
msg.Append(encode content)
socket.SendMessage(msg)
socket.SendMultipartMessage(msg)


/// Convenience method for sending the state of the kernel
Expand All @@ -191,12 +194,25 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
let kernelInfoRequest(msg : KernelMessage) (content : KernelRequest) =
let content =
{
protocol_version = [| 4; 0 |];
ipython_version = Some [| 1; 0; 0 |];
language_version = [| 1; 0; 0 |];
protocol_version = "4.0.0";
implementation = "ifsharp";
implementation_version = "4.0.0";
banner = "";
help_links = [||];
language = "fsharp";
language_info =
{
name = "fsharp";
version = "4.3.1.0";
mimetype = "text/x-fsharp";
file_extension = ".fs";
pygments_lexer = "";
codemirror_mode = "";
nbconvert_exporter = "";
};
}

sendStateBusy msg
sendMessage shellSocket msg "kernel_info_reply" content

/// Sends display data information immediately
Expand Down Expand Up @@ -407,11 +423,12 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =

/// Handles a 'shutdown_request' message
let shutdownRequest (msg : KernelMessage) (content : ShutdownRequest) =

logMessage "shutdown request"
// TODO: actually shutdown
let reply = { restart = true; }

sendMessage shellSocket msg "shutdown_reply" reply
sendMessage shellSocket msg "shutdown_reply" reply;
System.Environment.Exit(0)

/// Handles a 'history_request' message
let historyRequest (msg : KernelMessage) (content : HistoryRequest) =
Expand Down Expand Up @@ -442,7 +459,6 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
logMessage (sbOut.ToString())

while true do

let msg = recvMessage (shellSocket)

try
Expand All @@ -456,16 +472,27 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
| HistoryRequest(r) -> historyRequest msg r
| ObjectInfoRequest(r) -> objectInfoRequest msg r
| InspectRequest(r) -> inspectRequest msg r
| _ -> logMessage (String.Format("Unknown content type. msg_type is `{0}`", msg.Header.msg_type))
| _ -> logMessage (String.Format("Unknown content type on shell. msg_type is `{0}`", msg.Header.msg_type))
with
| ex -> handleException ex

let doControl() =
while true do
let msg = recvMessage (controlSocket)
try
match msg.Content with
| ShutdownRequest(r) -> shutdownRequest msg r
| _ -> logMessage (String.Format("Unexpected content type on control. msg_type is `{0}`", msg.Header.msg_type))
with
| ex -> handleException ex

/// Loops repeating message from the client
let doHeartbeat() =

try
while true do
hbSocket.Send(hbSocket.Receive())
let hb = hbSocket.ReceiveMultipartBytes() in
hbSocket.SendMultipartBytes(hb)
with
| ex -> handleException ex

Expand All @@ -485,5 +512,6 @@ type IfSharpKernel(connectionInformation : ConnectionInformation) =
/// Starts the kernel asynchronously
member __.StartAsync() =

Async.Start (async { doHeartbeat() } )
//Async.Start (async { doHeartbeat() } )
Async.Start (async { doShell() } )
Async.Start (async { doControl() } )
76 changes: 57 additions & 19 deletions src/IfSharp.Kernel/ShellMessages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -334,30 +334,68 @@ type CommOpen = obj

type KernelRequest = obj

type KernelReply_LanguageInfo =
{
// # Name of the programming language that the kernel implements.
// # Kernel included in IPython returns 'python'.
name: string;

// # Language version number.
// # It is Python version number (e.g., '2.7.3') for the kernel
// # included in IPython.
version: string;

// # mimetype for script files in this language
mimetype: string;

// # Extension including the dot, e.g. '.py'
file_extension: string;

// # Pygments lexer, for highlighting
// # Only needed if it differs from the 'name' field.
pygments_lexer: string;

// # Codemirror mode, for for highlighting in the notebook.
// # Only needed if it differs from the 'name' field.
codemirror_mode: string;

// # Nbconvert exporter, if notebooks written with this kernel should
// # be exported with something other than the general 'script'
// # exporter.
nbconvert_exporter: string;
}

type KernelReply_HelpLink = { text: string; url: string; }

type KernelReply =
{
// # Version of messaging protocol (mandatory).
// # Version of messaging protocol.
// # The first integer indicates major version. It is incremented when
// # there is any backward incompatible change.
// # The second integer indicates minor version. It is incremented when
// # there is any backward compatible change.
protocol_version: array<int>;

// # IPython version number (optional).
// # Non-python kernel backend may not have this version number.
// # The last component is an extra field, which may be 'dev' or
// # 'rc1' in development version. It is an empty string for
// # released version.
ipython_version: Option<array<obj>>;

// # Language version number (mandatory).
// # It is Python version number (e.g., [2, 7, 3]) for the kernel
// # included in IPython.
language_version: array<int>;

// # Programming language in which kernel is implemented (mandatory).
// # Kernel included in IPython returns 'python'.
language: string
protocol_version: string;

// # The kernel implementation name
// # (e.g. 'ipython' for the IPython kernel)
implementation: string;

// # Implementation version number.
// # The version number of the kernel's implementation
// # (e.g. IPython.__version__ for the IPython kernel)
implementation_version: string;

// # Information about the language of code for the kernel
language_info: KernelReply_LanguageInfo;
language: string;

// # A banner of information about the kernel,
// # which may be desplayed in console environments.
banner : string;

// # Optional: A list of dictionaries, each with keys 'text' and 'url'.
// # These will be displayed in the help menu in the notebook UI.
help_links: KernelReply_HelpLink array;
}

type KernelStatus =
Expand Down Expand Up @@ -483,7 +521,7 @@ type Header =

type KernelMessage =
{
Identifiers: list<string>;
Identifiers: list<byte[]>;
HmacSignature: string;
Header: Header;
ParentHeader: Header;
Expand Down
12 changes: 12 additions & 0 deletions src/IfSharp.Kernel/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Loading