jupyter

package module
v0.0.0-...-f8dea49 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2016 License: MIT Imports: 19 Imported by: 0

README

Go-Jupyter
==========

Go-Jupyter provides a framework for implementing Jupyter kernels in Go. This is a work-in-progress.

Documentation

Overview

Package jupyter implements the machinery necessary to implement and run a kernel for Jupyter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunKernel

func RunKernel(kernel Kernel, connInfo *ConnectionInfo) error

RunKernel is the main entry point to start the kernel. This is what is called by the kernel executable.

Types

type Completeness

type Completeness string
const (
	Complete            Completeness = "complete"
	Incomplete          Completeness = "incomplete"
	InvalidCode         Completeness = "invalid"
	UnknownCompleteness Completeness = "unknown"
)

type CompletionResult

type CompletionResult struct {
	// The list of all matches to the completion request.
	Matches []string

	// The range of text that should be replaced by the above matches
	// when a completion is accepted. Typically CursorEnd is the same
	// as CursorPos in the request.
	CursorStart int
	CursorEnd   int

	// Information that frontend plugins might use for extra display
	// information about completions.
	Metadata map[string]interface{}
}

type ConnectionInfo

type ConnectionInfo struct {
	Key             string `json:"key"`
	IP              string `json:"ip"`
	Transport       string `json:"transport"`
	SignatureScheme string `json:"signature_scheme"`

	StdinPort     int `json:"stdin_port"`
	ControlPort   int `json:"control_port"`
	IOPubPort     int `json:"iopub_port"`
	HeartbeatPort int `json:"hb_port"`
	ShellPort     int `json:"shell_port"`
}

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

func ReadConnectionFile

func ReadConnectionFile(connectionFilePath string) (*ConnectionInfo, error)

ReadConnectionFile reads the contents of the connection file at the specified path.

type ExecuteOptions

type ExecuteOptions struct {
	Silent       bool
	StoreHistory bool
}
type HelpLink struct {
	Text string `json:"text"`
	URL  string `json:"url"`
}

type Kernel

type Kernel interface {
	Info() KernelInfo
	Shutdown(restart bool) error
	Execute(code string, options ExecuteOptions) ([]interface{}, error)
	Complete(code string, cursorPos int) (*CompletionResult, error)
	Completeness(code string) Completeness
}

type KernelInfo

type KernelInfo struct {
	// 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.
	//
	// Note to implementers: the ProtocolVersion value returned by
	// Kernel.Info() will be ignored, and will be replaced by the
	// igo package.
	ProtocolVersion string `json:"protocol_version"`

	// The kernel implementation name
	// (e.g. 'ipython' for the IPython kernel)
	Implementation string `json:"implementation"`

	// Implementation version number.
	// The version number of the kernel's implementation
	// (e.g. IPython.__version__ for the IPython kernel)
	ImplementationVersion string `json:"implementation_version"`

	// Information about the language of code for the kernel
	LanguageInfo LanguageInfo `json:"language_info"`

	// A banner of information about the kernel,
	// which may be desplayed in console environments.
	Banner string `json:"banner,omitempty"`

	// A list of dictionaries, each with keys 'text' and 'url'.
	// These will be displayed in the help menu in the notebook UI.
	HelpLinks []HelpLink `json:"help_links,omitempty"`
}

type LanguageInfo

type LanguageInfo struct {
	// Name of the programming language in which kernel is implemented.
	// Kernel included in IPython returns 'python'.
	Name string `json:"name"`

	// Language version number.
	// It is Python version number (e.g., '2.7.3') for the kernel
	// included in IPython.
	Version string `json:"version"`

	// mimetype for script files in this language
	MimeType string `json:"mimetype"`

	// Extension including the dot, e.g. '.py'
	FileExtension string `json:"file_extension"`

	// Pygments lexer, for highlighting
	// Only needed if it differs from the 'name' field.
	PygmentsLexer string `json:"pygments_lexer,omitempty"`

	// Codemirror mode, for for highlighting in the notebook.
	// Only needed if it differs from the 'name' field.
	CodemirrorMode interface{} `json:"codemirror_mode,omitempty"`

	// Nbconvert exporter, if notebooks written with this kernel should
	// be exported with something other than the general 'script'
	// exporter.
	NbconvertExporter string `json:nbconvert_exporter,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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