kernel

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Package kernel is mostly copied from by https://github.com/gopherdata/gophernotes.

Package kernel is mostly copied from by https://github.com/gopherdata/gophernotes.

Package kernel is mostly copied from by https://github.com/gopherdata/gophernotes.

Package kernel is mostly copied from by https://github.com/gopherdata/gophernotes.

Package kernel is mostly copied from by https://github.com/gopherdata/gophernotes.

Index

Constants

View Source
const (
	// StreamStdout defines the stream name for standard out on the front-end. It
	// is used in `PublishWriteStream` to specify the stream to write to.
	StreamStdout = "stdout"

	// StreamStderr defines the stream name for standard error on the front-end. It
	// is used in `PublishWriteStream` to specify the stream to write to.
	StreamStderr = "stderr"
)

Variables

View Source
var (
	// ExecCounter is incremented each time we run user code in the notebook.
	// It cannot be defined in Kernel struct, or it will be always 1.
	ExecCounter = 0
)

Functions

This section is empty.

Types

type BundledMIMEData

type BundledMIMEData map[string]interface{}

bundledMIMEData holds data that can be presented in multiple formats. The keys are MIME types and the values are the data formatted with respect to its MIME type. All bundles should contain at least a "text/plain" representation with a string value.

type ComposedMsg

type ComposedMsg struct {
	Header       MsgHeader
	ParentHeader MsgHeader
	Metadata     map[string]interface{}
	Content      interface{}
}

ComposedMsg represents an entire message in a high-level structure.

func NewMsg

func NewMsg(msgType string, parent ComposedMsg) (ComposedMsg, error)

NewMsg creates a new ComposedMsg to respond to a parent message. This includes setting up its headers.

func WireMsgToComposedMsg

func WireMsgToComposedMsg(msgparts [][]byte, signkey []byte) (ComposedMsg, [][]byte, error)

WireMsgToComposedMsg translates a multipart ZMQ messages received from a socket into a ComposedMsg struct and a slice of return identities. This includes verifying the message signature.

func (ComposedMsg) ToWireMsg

func (msg ComposedMsg) ToWireMsg(signkey []byte) ([][]byte, error)

ToWireMsg translates a ComposedMsg into a multipart ZMQ message ready to send, and signs it. This does not add the return identities or the delimiter.

type ConnectionInfo

type ConnectionInfo struct {
	SignatureScheme string `json:"signature_scheme"`
	Transport       string `json:"transport"`
	StdinPort       int    `json:"stdin_port"`
	ControlPort     int    `json:"control_port"`
	IOPubPort       int    `json:"iopub_port"`
	HBPort          int    `json:"hb_port"`
	ShellPort       int    `json:"shell_port"`
	Key             string `json:"key"`
	IP              string `json:"ip"`
}

ConnectionInfo stores the contents of the kernel connection file created by Jupyter.

type Data

type Data struct {
	Data      BundledMIMEData `json:"data"`
	Metadata  BundledMIMEData `json:"metadata"`
	Transient BundledMIMEData `json:"transient"`
}

func Image

func Image(img image.Image) Data

Image converts an image.Image to DisplayData containing PNG []byte, or to DisplayData containing error if the conversion fails

func MakeData

func MakeData(mimeType string, data interface{}) Data
type HelpLink struct {
	Text string `json:"text"`
	URL  string `json:"url"`
}

HelpLink stores data to be displayed in the help menu of the notebook.

type Info

type Info struct {
	ProtocolVersion       string       `json:"protocol_version"`
	Implementation        string       `json:"implementation"`
	ImplementationVersion string       `json:"implementation_version"`
	LanguageInfo          LanguageInfo `json:"language_info"`
	Banner                string       `json:"banner"`
	HelpLinks             []HelpLink   `json:"help_links"`
}

Info holds information about the kubeflow kernel, for kernel_info_reply messages.

type InvalidSignatureError

type InvalidSignatureError struct{}

InvalidSignatureError is returned when the signature on a received message does not validate.

func (*InvalidSignatureError) Error

func (e *InvalidSignatureError) Error() string

type JupyterStreamWriter

type JupyterStreamWriter struct {
	// contains filtered or unexported fields
}

JupyterStreamWriter is an `io.Writer` implementation that writes the data to the notebook front-end.

func (*JupyterStreamWriter) Write

func (writer *JupyterStreamWriter) Write(p []byte) (int, error)

Write implements `io.Writer.Write` by publishing the data via `PublishWriteStream`

type Kernel

type Kernel struct {
	// ProtocolVersion defines the Jupyter protocol version.
	ProtocolVersion string
	// Version defines the gophernotes version.
	Version        string
	ConnectionFile string
	Manager        *manager.Manager
}

Kernel is a kubeflow kernel.

func New

func New(protocolVersion, version, connectionFile string, manager *manager.Manager) *Kernel

New creates a new kernel instance.

func (Kernel) RunKernel

func (k Kernel) RunKernel()

RunKernel is the main entry point to start the kernel.

type LanguageInfo

type LanguageInfo struct {
	Name              string `json:"name"`
	Version           string `json:"version"`
	MIMEType          string `json:"mimetype"`
	FileExtension     string `json:"file_extension"`
	PygmentsLexer     string `json:"pygments_lexer"`
	CodeMirrorMode    string `json:"codemirror_mode"`
	NBConvertExporter string `json:"nbconvert_exporter"`
}

LanguageInfo holds information about the language that this kernel executes code in.

type MsgHeader

type MsgHeader struct {
	MsgID           string `json:"msg_id"`
	Username        string `json:"username"`
	Session         string `json:"session"`
	MsgType         string `json:"msg_type"`
	ProtocolVersion string `json:"version"`
	Timestamp       string `json:"date"`
}

MsgHeader encodes header info for ZMQ messages.

type Socket

type Socket struct {
	Socket *zmq.Socket
	Lock   *sync.Mutex
}

Socket wraps a zmq socket with a lock which should be used to control write access.

func (*Socket) RunWithSocket

func (s *Socket) RunWithSocket(run func(socket *zmq.Socket) error) error

RunWithSocket invokes the `run` function after acquiring the `Socket.Lock` and releases the lock when done.

type SocketGroup

type SocketGroup struct {
	ShellSocket   Socket
	ControlSocket Socket
	StdinSocket   Socket
	IOPubSocket   Socket
	HBSocket      Socket
	Key           []byte
}

SocketGroup holds the sockets needed to communicate with the kernel, and the key for message signing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL