skyhook

package
v0.0.0-...-5d2d8d3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImageType     DataType = "image"
	VideoType              = "video"
	DetectionType          = "detection"
	ShapeType              = "shape"
	IntType                = "int"
	FloatsType             = "floats"
	ImListType             = "imlist"
	TextType               = "text"
	StringType             = "string"
	ArrayType              = "array"
	FileType               = "file"
	TableType              = "table"
	GeoImageType           = "geoimage"
	GeoJsonType            = "geojson"
)
View Source
const (
	PointShape    TypeOfShape = "point"
	LineShape                 = "line"
	PolyLineShape             = "polyline"
	BoxShape                  = "box"
	PolygonShape              = "polygon"
)
View Source
const Debug bool = false
View Source
const TailJobOpNumLines int = 1000

JobOp implementation that just keeps the latest 1000 lines of output This is used as a helper not as an actual JobOp -- since it can't stop the job. It is not thread-safe.

Variables

View Source
var DataSpecs = make(map[DataType]DataSpec)
View Source
var DataTypes = map[DataType]string{
	ImageType:     "Image",
	VideoType:     "Video",
	DetectionType: "Detection",
	ShapeType:     "Shape",
	IntType:       "Int",
	FloatsType:    "Floats",
	ImListType:    "Image List",
	TextType:      "Text",
	StringType:    "String",
	ArrayType:     "Array",
	FileType:      "File",
	TableType:     "Table",
	GeoImageType:  "Geo-Image",
	GeoJsonType:   "GeoJSON",
}
View Source
var ExecOpProviders = make(map[string]ExecOpProvider)
View Source
var ItemProviders = make(map[string]ItemProvider)

Functions

func AddExecOpImpl

func AddExecOpImpl(impl ExecOpImpl)

func Clip

func Clip(x, lo, hi int) int

func CopyFile

func CopyFile(src string, dst string) error
func CopyOrSymlink(srcFname string, dstFname string, symlink bool) error

func DecodeFile

func DecodeFile(t DataType, format string, metadata DataMetadata, fname string) (data interface{}, err error)

func DrawLineOnCells

func DrawLineOnCells(startX int, startY int, endX int, endY int, maxX int, maxY int) [][2]int

Use Bresenham's algorithm to get indices of cells to draw a line.

func EncodeTypes

func EncodeTypes(types []DataType) string

func Ext

func Ext(fname string) string

Like filepath.Ext but doesn't include the ".".

func Ffprobe

func Ffprobe(fname string) (width int, height int, duration float64, err error)

func FileExists

func FileExists(fname string) bool

func FloorDiv

func FloorDiv(a, b int) int

Returns a/b while taking floor (round-down) instead of truncating (round-towards-zero).

func GetExtFromFormat

func GetExtFromFormat(dtype DataType, format string) string

Forwards to ExtFromFormatDataSpec.GetExtFromFormat if available.

func GetGeometryBbox

func GetGeometryBbox(g *geojson.Geometry) gomapinfer.Rectangle

func GetImageDimsFromFile

func GetImageDimsFromFile(fname string) ([2]int, error)

func JsonGet

func JsonGet(baseURL string, path string, response interface{}) error

func JsonMarshal

func JsonMarshal(x interface{}) []byte

func JsonPost

func JsonPost(baseURL string, path string, request interface{}, response interface{}) error

func JsonPostForm

func JsonPostForm(baseURL string, path string, request urllib.Values, response interface{}) error

func JsonResponse

func JsonResponse(w http.ResponseWriter, x interface{})

func JsonUnmarshal

func JsonUnmarshal(bytes []byte, x interface{})

func Mod

func Mod(a, b int) int

func ParseFloat

func ParseFloat(str string) float64

func ParseInt

func ParseInt(str string) int

func ParseJsonRequest

func ParseJsonRequest(w http.ResponseWriter, r *http.Request, x interface{}) error

func ParseJsonResponse

func ParseJsonResponse(resp *http.Response, response interface{}) error

func PerFrame

func PerFrame(items []Item, f func(pos int, datas []interface{}) error) error

Read multiple sequence-type datas one by one and pass to the callback [f].

func ReadData

func ReadData(t DataType, format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func ReadJSONFile

func ReadJSONFile(fname string, res interface{})

func ReadJsonData

func ReadJsonData(r io.Reader, x interface{}) error

Reads data that was written by WriteJsonData.

func ReadTextFile

func ReadTextFile(fname string) string

func SeedRand

func SeedRand()

func SynchronizedReader

func SynchronizedReader(items []Item, n int, f func(pos int, length int, datas []interface{}) error) error

Read multiple sequence-type datas in a synchronized fashion, in chunks of length [n]. [f] is a callback to pass each chunk of data to.

func TrySynchronizedReader

func TrySynchronizedReader(items []Item, n int, f func(pos int, length int, datas []interface{}) error) error

Read multiple datas and try to break them up into chunks of length n. If there are any non-sequence-type datas, then we pass all the datas to the callback in one call. In that case, the length passed to the call is -1.

func WriteJsonData

func WriteJsonData(x interface{}, w io.Writer) error

Write x with JSON-encoding to a stream. Before writing the JSON-encoded data, we write the length of the data.

Types

type AnnotateDataset

type AnnotateDataset struct {
	ID      int
	Dataset Dataset
	Inputs  []ExecParent
	Tool    string
	Params  string
}

type ArrayDataSpec

type ArrayDataSpec struct{}

func (ArrayDataSpec) Append

func (s ArrayDataSpec) Append(data interface{}, more interface{}) interface{}

func (ArrayDataSpec) DecodeMetadata

func (s ArrayDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (ArrayDataSpec) GetDefaultExtAndFormat

func (s ArrayDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (ArrayDataSpec) Length

func (s ArrayDataSpec) Length(data interface{}) int

func (ArrayDataSpec) Read

func (s ArrayDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (ArrayDataSpec) ReadStream

func (s ArrayDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (ArrayDataSpec) Reader

func (s ArrayDataSpec) Reader(format string, metadata DataMetadata, r io.Reader) SequenceReader

func (ArrayDataSpec) Slice

func (s ArrayDataSpec) Slice(data interface{}, i int, j int) interface{}

func (ArrayDataSpec) Write

func (s ArrayDataSpec) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (ArrayDataSpec) WriteStream

func (s ArrayDataSpec) WriteStream(data interface{}, w io.Writer) error

func (ArrayDataSpec) Writer

func (s ArrayDataSpec) Writer(format string, metadata DataMetadata, w io.Writer) SequenceWriter

type ArrayMetadata

type ArrayMetadata struct {
	Width    int `json:",omitempty"`
	Height   int `json:",omitempty"`
	Channels int `json:",omitempty"`

	// uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64
	Type string `json:",omitempty"`
}

func (ArrayMetadata) BytesPerElement

func (m ArrayMetadata) BytesPerElement() int

func (ArrayMetadata) Size

func (m ArrayMetadata) Size() int

Bytes per primitive.

func (ArrayMetadata) Update

func (m ArrayMetadata) Update(other DataMetadata) DataMetadata

type ArrayReader

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

func (ArrayReader) Close

func (r ArrayReader) Close()

func (ArrayReader) Read

func (r ArrayReader) Read(n int) (interface{}, error)

type ArrayStreamHeader

type ArrayStreamHeader struct {
	Length          int
	BytesPerElement int
}

type ArrayWriter

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

func (ArrayWriter) Close

func (w ArrayWriter) Close() error

func (ArrayWriter) Write

func (w ArrayWriter) Write(data interface{}) error

type ChanReader

type ChanReader struct {
	Ch chan Image
}

func (*ChanReader) Close

func (rd *ChanReader) Close()

func (*ChanReader) Read

func (rd *ChanReader) Read() (Image, error)

type ClosingSequenceReader

type ClosingSequenceReader struct {
	ReadCloser io.ReadCloser
	Reader     SequenceReader
}

SequenceReader that closes an io.ReadCloser on Close.

func (ClosingSequenceReader) Close

func (r ClosingSequenceReader) Close()

func (ClosingSequenceReader) Read

func (r ClosingSequenceReader) Read(n int) (interface{}, error)

type ClosingSequenceWriter

type ClosingSequenceWriter struct {
	WriteCloser io.WriteCloser
	Writer      SequenceWriter
}

SequenceWriter that closses an io.WriteCloser on Close.

func (ClosingSequenceWriter) Close

func (w ClosingSequenceWriter) Close() error

func (ClosingSequenceWriter) Write

func (w ClosingSequenceWriter) Write(data interface{}) error

type Cmd

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

func Command

func Command(prefix string, opts CommandOptions, command string, args ...string) *Cmd

func MakeVideo

func MakeVideo(rd VideoReader, dims [2]int, rate [2]int, opts MakeVideoOptions) *Cmd

func (*Cmd) Stderr

func (cmd *Cmd) Stderr() io.ReadCloser

func (*Cmd) Stdin

func (cmd *Cmd) Stdin() io.WriteCloser

func (*Cmd) Stdout

func (cmd *Cmd) Stdout() io.ReadCloser

func (*Cmd) Wait

func (cmd *Cmd) Wait() error

type CmdError

type CmdError struct {
	ExitError error
	Lines     []string
}

func (CmdError) Error

func (e CmdError) Error() string

type ColumnSpec

type ColumnSpec struct {
	Label string
	// data type, one of "string", "int", "float64"
	Type string
}

type CommandOptions

type CommandOptions struct {
	NoStdin       bool
	NoStdout      bool
	NoStderr      bool
	NoPrintStderr bool
	// Function to arbitrary modify the exec.Cmd, e.g., set working directory.
	// This is called just before starting the process.
	F func(*exec.Cmd)
	// Whether to only print stderr if debug mode is on.
	OnlyDebug bool
	// Whether to keep not just the last stderr line, but all lines, in case of error.
	AllStderrLines bool
}

type ContainerRequest

type ContainerRequest struct {
	Node           Runnable
	JobID          *int
	CoordinatorURL string
	InstanceID     string
}

coordinator->worker request creation of a new container

type ContainerResponse

type ContainerResponse struct {
	// request/container UUID
	UUID string
}

type DataMetadata

type DataMetadata interface {
	// Produce new metadata where fields that are specified by other overwrite
	// fields in the current metadata.
	Update(other DataMetadata) DataMetadata
}

Metadata can mostly be anything but must support Update.

type DataSpec

type DataSpec interface {
	// Decode JSON-encoded metadata into a metadata object.
	DecodeMetadata(rawMetadata string) DataMetadata
	// Read data that has been written via WriteStream.
	ReadStream(r io.Reader) (data interface{}, err error)
	// Write data for reading via ReadStream.
	WriteStream(data interface{}, w io.Writer) error

	// Read data from storage.
	// format is the Item.Format which data types can use to describe how the data is stored.
	Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)
	// Write data to storage.
	Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

	// Given some data, return a suggested file extension and format to store it with.
	GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)
}

Specifies a data type.

type DataType

type DataType string

func DecodeTypes

func DecodeTypes(s string) []DataType

type Dataset

type Dataset struct {
	ID   int
	Name string

	// data or computed
	Type string

	DataType DataType
	Metadata string

	// nil unless Type=computed
	Hash *string
}

func (Dataset) DBFname

func (ds Dataset) DBFname() string

func (Dataset) DataSpec

func (ds Dataset) DataSpec() DataSpec

func (Dataset) Dirname

func (ds Dataset) Dirname() string

func (Dataset) GraphID

func (node Dataset) GraphID() GraphID

func (Dataset) GraphParents

func (node Dataset) GraphParents() map[string]GraphID

func (Dataset) LocalHash

func (ds Dataset) LocalHash() []byte

func (Dataset) Mkdir

func (ds Dataset) Mkdir()

func (Dataset) Remove

func (ds Dataset) Remove()

type Detection

type Detection struct {
	Left   int
	Top    int
	Right  int
	Bottom int

	// Optional metadata
	Category string            `json:",omitempty"`
	TrackID  int               `json:",omitempty"`
	Score    float64           `json:",omitempty"`
	Metadata map[string]string `json:",omitempty"`
}

func (Detection) CenterDistance

func (d Detection) CenterDistance(other Detection) float64

func (Detection) Rescale

func (d Detection) Rescale(origDims [2]int, newDims [2]int) Detection

type DetectionJsonSpec

type DetectionJsonSpec struct{}

func (DetectionJsonSpec) Append

func (s DetectionJsonSpec) Append(data interface{}, more interface{}) interface{}

func (DetectionJsonSpec) DecodeData

func (s DetectionJsonSpec) DecodeData(bytes []byte) (interface{}, error)

func (DetectionJsonSpec) DecodeMetadata

func (s DetectionJsonSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (DetectionJsonSpec) GetEmptyMetadata

func (s DetectionJsonSpec) GetEmptyMetadata() (metadata DataMetadata)

func (DetectionJsonSpec) Length

func (s DetectionJsonSpec) Length(data interface{}) int

func (DetectionJsonSpec) Slice

func (s DetectionJsonSpec) Slice(data interface{}, i int, j int) interface{}

type DetectionMetadata

type DetectionMetadata struct {
	CanvasDims [2]int   `json:",omitempty"`
	Categories []string `json:",omitempty"`
}

func (DetectionMetadata) Update

type EndRequest

type EndRequest struct {
	UUID string
}

release a container

type ErrorSequenceReader

type ErrorSequenceReader struct {
	Error error
}

SequenceReader/SequenceWriter that return errors.

func (ErrorSequenceReader) Close

func (r ErrorSequenceReader) Close()

func (ErrorSequenceReader) Read

func (r ErrorSequenceReader) Read(n int) (interface{}, error)

type ErrorSequenceWriter

type ErrorSequenceWriter struct {
	Error error
}

func (ErrorSequenceWriter) Close

func (w ErrorSequenceWriter) Close() error

func (ErrorSequenceWriter) Write

func (w ErrorSequenceWriter) Write(data interface{}) error

type ExecBeginRequest

type ExecBeginRequest struct {
	Node           Runnable
	JobID          *int
	CoordinatorURL string
}

worker->container

type ExecBeginResponse

type ExecBeginResponse struct {
	Parallelism int
}

type ExecInput

type ExecInput struct {
	Name string
	// nil if input can be any type
	DataTypes []DataType
	// true if this node can accept multiple inputs for this name
	Variable bool
}

type ExecNode

type ExecNode struct {
	ID     int
	Name   string
	Op     string
	Params string

	// currently configured parents for each input
	Parents map[string][]ExecParent
}

func (ExecNode) GetInputTypes

func (node ExecNode) GetInputTypes() map[string][]DataType

func (ExecNode) GetInputs

func (node ExecNode) GetInputs() []ExecInput

func (ExecNode) GetOp

func (node ExecNode) GetOp() ExecOpProvider

func (ExecNode) GetOutputTypes

func (node ExecNode) GetOutputTypes() map[string]DataType

func (ExecNode) GetOutputs

func (node ExecNode) GetOutputs() []ExecOutput

type ExecOp

type ExecOp interface {
	Parallelism() int
	Apply(task ExecTask) error
	Close()
}

type ExecOpConfig

type ExecOpConfig struct {
	ID          string
	Name        string
	Description string
}

Config of the ExecOp for front-end.

type ExecOpImpl

type ExecOpImpl struct {
	Config       ExecOpConfig
	Requirements func(node Runnable) map[string]int
	GetTasks     func(node Runnable, items map[string][][]Item) ([]ExecTask, error)
	Prepare      func(url string, node Runnable) (ExecOp, error)

	// only one should be set (static/dynamic)
	ImageName    string
	GetImageName func(node Runnable) (string, error)

	// static specification of inputs/outputs
	// one of dynamic/static should be set
	Inputs  []ExecInput
	Outputs []ExecOutput

	// dynamic specification of inputs/outputs
	// one of dynamic/static should be set
	GetInputs  func(params string) []ExecInput
	GetOutputs func(params string, inputTypes map[string][]DataType) []ExecOutput

	// optional; if set, op is considered "incremental"
	Incremental     bool
	GetOutputKeys   func(node ExecNode, inputs map[string][][]string) []string
	GetNeededInputs func(node ExecNode, outputs []string) map[string][][]string

	// more various optional functions
	GetJobOp   func(node Runnable) (JobOp, string)
	Virtualize func(node ExecNode) *VirtualNode
	Resolve    func(node *VirtualNode, inputDatasets map[string][]Dataset, items map[string][][]Item) ExecutionGraph
}

A helper to implement an ExecOpProvider as a struct. This way optional methods can be omitted and defaults used instead. It can be compiled to an ExecOpProvider by wrapping in an ExecOpImplProvider.

type ExecOpImplProvider

type ExecOpImplProvider struct {
	Impl ExecOpImpl
}

func (ExecOpImplProvider) Config

func (p ExecOpImplProvider) Config() ExecOpConfig

func (ExecOpImplProvider) GetImageName

func (p ExecOpImplProvider) GetImageName(node Runnable) (string, error)

func (ExecOpImplProvider) GetInputs

func (p ExecOpImplProvider) GetInputs(params string) []ExecInput

func (ExecOpImplProvider) GetJobOp

func (p ExecOpImplProvider) GetJobOp(node Runnable) (JobOp, string)

func (ExecOpImplProvider) GetNeededInputs

func (p ExecOpImplProvider) GetNeededInputs(node ExecNode, outputs []string) map[string][][]string

func (ExecOpImplProvider) GetOutputKeys

func (p ExecOpImplProvider) GetOutputKeys(node ExecNode, inputs map[string][][]string) []string

func (ExecOpImplProvider) GetOutputs

func (p ExecOpImplProvider) GetOutputs(params string, inputTypes map[string][]DataType) []ExecOutput

func (ExecOpImplProvider) GetTasks

func (p ExecOpImplProvider) GetTasks(node Runnable, items map[string][][]Item) ([]ExecTask, error)

func (ExecOpImplProvider) IsIncremental

func (p ExecOpImplProvider) IsIncremental() bool

func (ExecOpImplProvider) Prepare

func (p ExecOpImplProvider) Prepare(url string, node Runnable) (ExecOp, error)

func (ExecOpImplProvider) Requirements

func (p ExecOpImplProvider) Requirements(node Runnable) map[string]int

func (ExecOpImplProvider) Resolve

func (p ExecOpImplProvider) Resolve(node *VirtualNode, inputDatasets map[string][]Dataset, items map[string][][]Item) ExecutionGraph

func (ExecOpImplProvider) Virtualize

func (p ExecOpImplProvider) Virtualize(node ExecNode) *VirtualNode

type ExecOpProvider

type ExecOpProvider interface {
	// Returns config for front-end.
	Config() ExecOpConfig
	// Returns resource requirements.
	Requirements(node Runnable) map[string]int
	// Returns list of tasks.
	// items: is a map: input name -> input dataset index -> items in that dataset
	GetTasks(node Runnable, items map[string][][]Item) ([]ExecTask, error)
	// Prepare the ExecOp for a node.
	Prepare(url string, node Runnable) (ExecOp, error)
	// Determines the input specification of a node.
	GetInputs(params string) []ExecInput
	// Determines the output specification of a node.
	GetOutputs(params string, inputTypes map[string][]DataType) []ExecOutput

	// Incremental ops support partial computation of their outputs.
	// This is only possible for concrete nodes (Resolve must return nil).
	IsIncremental() bool
	// Must be implemented if Incremental.
	// GetOutputKeys returns all output keys that would be produced given a set of input keys.
	// GetNeededInputs returns the input keys that are needed to compute a given subset of output keys.
	GetOutputKeys(node ExecNode, inputs map[string][][]string) []string
	GetNeededInputs(node ExecNode, outputs []string) map[string][][]string

	// Docker image name
	GetImageName(node Runnable) (string, error)

	// Optional system to provide customized state to store in ExecNode jobs.
	// For example, when training a model, we may want to store the loss history.
	// Can return nil to use defaults.
	// Second return value is the view of the JobOp, empty string to use default view.
	GetJobOp(node Runnable) (JobOp, string)

	// Virtualize is called when constructing an initial ExecutionGraph.
	// For example, if(A) { input B } else { input C } can be implemented by:
	// - Virtualize should return VirtualNode requiring only A
	// - Resolve can load A, and output a new graph that includes B or C depending on A
	Virtualize(node ExecNode) *VirtualNode

	// Optional system for pre-processing steps, dynamic execution graphs, etc.
	// Given a VirtualNode, returns a subgraph of new VirtualNodes that implement it.
	// Or nil if the VirtualNode is already OK.
	// Resolve is called just before executing the node.
	Resolve(node *VirtualNode, inputDatasets map[string][]Dataset, items map[string][][]Item) ExecutionGraph
}

func GetExecOp

func GetExecOp(opName string) ExecOpProvider

type ExecOutput

type ExecOutput struct {
	Name     string
	DataType DataType
}

type ExecParent

type ExecParent struct {
	// "n" for ExecNode, "d" for Dataset
	Type string
	ID   int

	// name of ExecNode output that is being input
	Name string

	// the data type of this parent
	DataType DataType
}

func (ExecParent) String

func (p ExecParent) String() string

type ExecTask

type ExecTask struct {
	// For incremental operations, this must be the output key that will be created by this task.
	// TODO: operation may need to produce multiple output keys at some task
	// For other operations, I think this can be arbitrary, but usually it's still related to the output key
	Key string

	// Generally maps from input name to list of items in each dataset at that input
	Items map[string][][]Item

	Metadata string
}

type ExecTaskRequest

type ExecTaskRequest struct {
	Task ExecTask
}

coordinator->container

type ExecutionGraph

type ExecutionGraph map[GraphID]Node

An execption graph, that maps GraphIDs to Nodes.

func (ExecutionGraph) GetHashStrings

func (graph ExecutionGraph) GetHashStrings() map[GraphID]string

func (ExecutionGraph) GetHashes

func (graph ExecutionGraph) GetHashes() map[GraphID][]byte

Returns hashes of all nodes in the graph.

type ExtFromFormatDataSpec

type ExtFromFormatDataSpec interface {
	DataSpec
	// Given a format, return the standard extension corresponding to the format.
	// If a DataSpec doesn't implement this function, callers should use the format
	// as the file extension.
	GetExtFromFormat(format string) (ext string)
}

type FfmpegReader

type FfmpegReader struct {
	Cmd    *Cmd
	Stdout io.ReadCloser
	Width  int
	Height int
	Buf    []byte
}

func ReadFfmpeg

func ReadFfmpeg(fname string, dims [2]int, rate [2]int, opts ReadFfmpegOptions) *FfmpegReader

func (*FfmpegReader) Close

func (rd *FfmpegReader) Close()

func (*FfmpegReader) Read

func (rd *FfmpegReader) Read() (Image, error)

type FileDataSpec

type FileDataSpec interface {
	DataSpec
	// Read data directly from a file.
	ReadFile(format string, metadata DataMetadata, fname string) (data interface{}, err error)
	// Write data directly to a file.
	WriteFile(data interface{}, format string, metadata DataMetadata, fname string) error
}

type FileMetadata

type FileMetadata struct {
	Filename string `json:",omitempty"`
}

func (FileMetadata) Update

func (m FileMetadata) Update(other DataMetadata) DataMetadata

type FileSequenceDataSpec

type FileSequenceDataSpec interface {
	SequenceDataSpec
	FileReader(format string, metadata DataMetadata, fname string) SequenceReader
	FileWriter(format string, metadata DataMetadata, fname string) SequenceWriter
}

Sequence data types that want to have special functionality when reading from local disk can implement FileReader and FileWriter.

type FileStreamHeader

type FileStreamHeader struct {
	Length int
}

type FileTypeDataSpec

type FileTypeDataSpec struct{}

func (FileTypeDataSpec) DecodeMetadata

func (s FileTypeDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (FileTypeDataSpec) GetDefaultExtAndFormat

func (s FileTypeDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (FileTypeDataSpec) Read

func (s FileTypeDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (FileTypeDataSpec) ReadStream

func (s FileTypeDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (FileTypeDataSpec) Write

func (s FileTypeDataSpec) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (FileTypeDataSpec) WriteStream

func (s FileTypeDataSpec) WriteStream(data interface{}, w io.Writer) error

type FloatJsonSpec

type FloatJsonSpec struct{}

func (FloatJsonSpec) Append

func (s FloatJsonSpec) Append(data interface{}, more interface{}) interface{}

func (FloatJsonSpec) DecodeData

func (s FloatJsonSpec) DecodeData(bytes []byte) (interface{}, error)

func (FloatJsonSpec) DecodeMetadata

func (s FloatJsonSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (FloatJsonSpec) GetEmptyMetadata

func (s FloatJsonSpec) GetEmptyMetadata() (metadata DataMetadata)

func (FloatJsonSpec) Length

func (s FloatJsonSpec) Length(data interface{}) int

func (FloatJsonSpec) Slice

func (s FloatJsonSpec) Slice(data interface{}, i int, j int) interface{}

type GeoBbox

type GeoBbox [4]float64

func (GeoBbox) FromGeo

func (bbox GeoBbox) FromGeo(p [2]float64) [2]float64

Convert from longitude-latitude to fractional position in image.

func (GeoBbox) Rect

func (bbox GeoBbox) Rect() gomapinfer.Rectangle

func (GeoBbox) ToGeo

func (bbox GeoBbox) ToGeo(p [2]float64) [2]float64

Convert from relative fractional position in image to longitude-latitude.

type GeoImageDataSpec

type GeoImageDataSpec struct{}

func (GeoImageDataSpec) DecodeMetadata

func (s GeoImageDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (GeoImageDataSpec) GetDefaultExtAndFormat

func (s GeoImageDataSpec) GetDefaultExtAndFormat(data interface{}, metadata_ DataMetadata) (ext string, format string)

func (GeoImageDataSpec) Read

func (s GeoImageDataSpec) Read(format string, metadata_ DataMetadata, r io.Reader) (data interface{}, err error)

func (GeoImageDataSpec) ReadStream

func (s GeoImageDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (GeoImageDataSpec) Write

func (s GeoImageDataSpec) Write(data interface{}, format string, metadata_ DataMetadata, w io.Writer) error

func (GeoImageDataSpec) WriteStream

func (s GeoImageDataSpec) WriteStream(data interface{}, w io.Writer) error

type GeoImageItemSource

type GeoImageItemSource struct {
	Item Item
	// Copy the source image to this offset in our image.
	// Coordinates can be negative. For example, (-50, -50) means that (50, 50) in
	// the source item is placed at (0, 0) in our image.
	Offset [2]int
}

type GeoImageMetadata

type GeoImageMetadata struct {
	// either "webmercator" or "custom"
	ReferenceType string `json:",omitempty"`

	// For "webmercator" georeference type.
	// Zoom, X, and Y specify the cell that the image spans.
	Zoom int `json:",omitempty"`
	X    int `json:",omitempty"`
	Y    int `json:",omitempty"`
	// Scale specifies resolution of each cell. Usually it is 256.
	Scale int `json:",omitempty"`
	// Offset specifies offset from the X,Y tile.
	Offset [2]int `json:",omitempty"`

	// Width and height corresponding to the specified zoom and scale.
	// This does not necessarily match the image width and height, but if image
	// is resized from this width and height then the x / y axis must still be proportional.
	Width  int `json:",omitempty"`
	Height int `json:",omitempty"`

	// For custom formats, optionally store the longitude-latitude of bottom-left and top-right corners.
	// If set, we assume that the projection is like Mercator where compass direction matches image axes.
	// If not set, we cannot transform between longitude-latitude and pixel coordinates.
	Bbox [4]float64 `json:",omitempty"`

	// image source type
	// "local": image is stored in JPEG file
	// "url": image comes from a tile server
	// "dataset": image comes from another dataset
	SourceType string `json:",omitempty"`

	// For URL type, the tile server URL.
	URL string `json:",omitempty"`

	// For dataset type, define the source items.
	Items []GeoImageItemSource `json:",omitempty"`
}

func (GeoImageMetadata) DownloadTile

func (m GeoImageMetadata) DownloadTile(i, j int) (Image, error)

Assuming SourceType=="url", download a tile in this image from the URL.

func (GeoImageMetadata) GetBbox

func (m GeoImageMetadata) GetBbox() GeoBbox

Get the bounding box of this image.

func (GeoImageMetadata) Update

func (m GeoImageMetadata) Update(other DataMetadata) DataMetadata

type GeoJsonData

type GeoJsonData struct {
	Collection *geojson.FeatureCollection
}

type GeoJsonDataSpec

type GeoJsonDataSpec struct{}

func (GeoJsonDataSpec) DecodeMetadata

func (s GeoJsonDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (GeoJsonDataSpec) GetDefaultExtAndFormat

func (s GeoJsonDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (GeoJsonDataSpec) Read

func (s GeoJsonDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (interface{}, error)

func (GeoJsonDataSpec) ReadStream

func (s GeoJsonDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (GeoJsonDataSpec) Write

func (s GeoJsonDataSpec) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (GeoJsonDataSpec) WriteStream

func (s GeoJsonDataSpec) WriteStream(data interface{}, w io.Writer) error

type GraphID

type GraphID struct {
	// Either "exec" or "dataset"
	Type string
	// ID of ExecNode or Dataset
	ID int
	// For virtual nodes, some unique key for it
	VirtualKey string
}

ID type in execution graph.

type Image

type Image struct {
	Width  int
	Height int
	Bytes  []byte
}

func ImageFromBytes

func ImageFromBytes(width int, height int, bytes []byte) Image

func ImageFromFile

func ImageFromFile(fname string) (Image, error)

func ImageFromGoImage

func ImageFromGoImage(im image.Image) Image

func ImageFromJPGReader

func ImageFromJPGReader(rd io.Reader) (Image, error)

func ImageFromPNGReader

func ImageFromPNGReader(rd io.Reader) (Image, error)

func NewImage

func NewImage(width int, height int) Image

func (Image) AsImage

func (im Image) AsImage() image.Image

func (Image) AsJPG

func (im Image) AsJPG() ([]byte, error)

func (Image) AsPNG

func (im Image) AsPNG() ([]byte, error)

func (Image) At

func (im Image) At(i int, j int) color.Color

func (Image) Bounds

func (im Image) Bounds() image.Rectangle

func (Image) ColorModel

func (im Image) ColorModel() color.Model

func (Image) Copy

func (im Image) Copy() Image

func (Image) Crop

func (im Image) Crop(sx, sy, ex, ey int) Image

func (Image) DrawImage

func (im Image) DrawImage(left int, top int, other Image)

func (Image) DrawLine

func (im Image) DrawLine(sx, sy, ex, ey int, width int, color [3]uint8)

func (Image) DrawRectangle

func (im Image) DrawRectangle(left, top, right, bottom int, width int, color [3]uint8)

func (Image) DrawText

func (im Image) DrawText(text RichText)

func (Image) FillRectangle

func (im Image) FillRectangle(left, top, right, bottom int, color [3]uint8)

func (Image) GetRGB

func (im Image) GetRGB(i int, j int) [3]uint8

func (Image) Resize

func (im Image) Resize(width int, height int) Image

Resize using simple nearest-neighbor method.

func (Image) Set

func (im Image) Set(i int, j int, c color.Color)

func (Image) SetRGB

func (im Image) SetRGB(i int, j int, color [3]uint8)

func (Image) ToBytes

func (im Image) ToBytes() []byte

type ImageDataSpec

type ImageDataSpec struct{}

func (ImageDataSpec) Append

func (s ImageDataSpec) Append(data interface{}, more interface{}) interface{}

func (ImageDataSpec) DecodeMetadata

func (s ImageDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (ImageDataSpec) GetDefaultExtAndFormat

func (s ImageDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (ImageDataSpec) GetExtFromFormat

func (s ImageDataSpec) GetExtFromFormat(format string) (ext string)

func (ImageDataSpec) GetMetadataFromFile

func (s ImageDataSpec) GetMetadataFromFile(fname string) (format string, metadata DataMetadata, err error)

func (ImageDataSpec) Length

func (s ImageDataSpec) Length(data interface{}) int

func (ImageDataSpec) Read

func (s ImageDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (ImageDataSpec) ReadStream

func (s ImageDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (ImageDataSpec) Reader

func (s ImageDataSpec) Reader(format string, metadata DataMetadata, r io.Reader) SequenceReader

func (ImageDataSpec) Slice

func (s ImageDataSpec) Slice(data interface{}, i int, j int) interface{}

func (ImageDataSpec) Write

func (s ImageDataSpec) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (ImageDataSpec) WriteStream

func (s ImageDataSpec) WriteStream(data interface{}, w io.Writer) error

func (ImageDataSpec) Writer

func (s ImageDataSpec) Writer(format string, metadata DataMetadata, w io.Writer) SequenceWriter

type ImageStreamHeader

type ImageStreamHeader struct {
	Width           int
	Height          int
	Channels        int
	Length          int
	BytesPerElement int
}

type IntJsonSpec

type IntJsonSpec struct{}

func (IntJsonSpec) Append

func (s IntJsonSpec) Append(data interface{}, more interface{}) interface{}

func (IntJsonSpec) DecodeData

func (s IntJsonSpec) DecodeData(bytes []byte) (interface{}, error)

func (IntJsonSpec) DecodeMetadata

func (s IntJsonSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (IntJsonSpec) GetEmptyMetadata

func (s IntJsonSpec) GetEmptyMetadata() (metadata DataMetadata)

func (IntJsonSpec) Length

func (s IntJsonSpec) Length(data interface{}) int

func (IntJsonSpec) Slice

func (s IntJsonSpec) Slice(data interface{}, i int, j int) interface{}

type IntMetadata

type IntMetadata struct {
	Categories []string `json:",omitempty"`
}

func (IntMetadata) Update

func (m IntMetadata) Update(other DataMetadata) DataMetadata

type Item

type Item struct {
	Dataset  Dataset
	Key      string
	Ext      string
	Format   string
	Metadata string

	// nil to use default storage provider for LoadData / UpdateData
	Provider     *string
	ProviderInfo *string
}

func (Item) CopyTo

func (item Item) CopyTo(fname string, format string, symlink bool) error

Copy the data to the specified filename with specified output format. If symlink is true, we try to symlink when possible. In some cases, copying data isn't possible and we need to actually load it (decode+re-encode).

func (Item) DataSpec

func (item Item) DataSpec() DataSpec

func (Item) DecodeMetadata

func (item Item) DecodeMetadata() DataMetadata

func (Item) Fname

func (item Item) Fname() string

func (Item) GetProvider

func (item Item) GetProvider() ItemProvider

func (Item) LoadData

func (item Item) LoadData() (interface{}, DataMetadata, error)

func (Item) LoadReader

func (item Item) LoadReader() (SequenceReader, DataMetadata)

func (Item) LoadWriter

func (item Item) LoadWriter() SequenceWriter

func (Item) Remove

func (item Item) Remove()

func (Item) UpdateData

func (item Item) UpdateData(data interface{}, metadata DataMetadata) error

type ItemProvider

type ItemProvider struct {
	LoadData func(item Item) (interface{}, DataMetadata, error)
	// optional: we panic if UpdateData is called without being supported
	UpdateData func(item Item, data interface{}, metadata DataMetadata) error
	// optional: we return empty string if Fname is called without being supported
	// caller then needs to fallback to loading the data
	Fname func(item Item) string
}
var DefaultItemProvider ItemProvider

func VirtualProvider

func VirtualProvider(f func(item Item, data interface{}, metadata DataMetadata) (interface{}, DataMetadata, error), visibleFname bool) ItemProvider

helper function to create virtual item providers virtual providers reference another dataset, calling LoadData on the other dataset but then applying some function on the data before returning it in virtual providers, ProviderInfo is JSON-encoded item in other dataset TODO: but this means stack of virtual providers will make item metadata keep getting longer and longer...

type Job

type Job struct {
	ID        int
	Name      string
	Type      string
	Op        string
	Metadata  string
	StartTime time.Time
	State     string

	// If the job succeeds, Done=true and Error="".
	// If it fails, then Done=true and Error is set.
	// If Done=false it implies the job is still running.
	Done  bool
	Error string
}

type JobOp

type JobOp interface {
	// Update the job given the newly received lines from the job output.
	Update(lines []string)
	// Encode the current job state
	Encode() string
	// Stop this job.
	Stop() error
}

type JobUpdate

type JobUpdate struct {
	JobID int
	Lines []string
}

type MakeVideoOptions

type MakeVideoOptions struct {
	// The destination of the encoded video data.
	// One of Fname or Writer must be set.
	Fname  string
	Writer io.Writer
}

type MetadataFromFileDataSpec

type MetadataFromFileDataSpec interface {
	DataSpec
	// Given a filename, which should correspond to an actual file stored on disk,
	// returns a suitable format and metadata for reading that file.
	GetMetadataFromFile(fname string) (format string, metadata DataMetadata, err error)
}

type ModelJobState

type ModelJobState struct {
	TrainLoss []float64
	ValLoss   []float64
}

type NoMetadata

type NoMetadata struct{}

func (NoMetadata) Update

func (m NoMetadata) Update(other DataMetadata) DataMetadata

type Node

type Node interface {
	// Parents of this node.
	// These are other nodes that must be executed before this node can be executed.
	// Key defines what kind of parent it is.
	GraphParents() map[string]GraphID
	// The local hash at this node.
	// The hash of a node is computed by merging hash of its parents with its local hash.
	LocalHash() []byte
	// unique identifier
	GraphID() GraphID
}

A node in an execution pipeline. This is either an execution node (VirtualNode) or a dataset (Dataset).

type PDDImageOptions

type PDDImageOptions struct {
	Mode         string
	MaxDimension int
	Width        int
	Height       int
	Multiple     int
}

Pytorch default dataset parameters. This configures skyhook.pytorch.dataset.default, and goes JSON-encoded in PytorchTrainParams.Dataset.Params.

type PDDParams

type PDDParams struct {
	InputOptions []interface{}
	ValPercent   int
}

type PIInputOption

type PIInputOption struct {
	Idx   int
	Value string
}

type PIOutputDataset

type PIOutputDataset struct {
	ComponentIdx int
	Layer        string
	DataType     DataType
}

type PRestore

type PRestore struct {
	SrcPrefix    string
	DstPrefix    string
	SkipPrefixes string
}

Pytorch restore models

type PTDParams

type PTDParams struct {
	LearningRate  float64
	Optimizer     string
	BatchSize     int
	AutoBatchSize bool
	StopCondition struct {
		MaxEpochs      int
		ScoreEpsilon   float64
		ScoreMaxEpochs int
	}
	ModelSaver struct {
		Mode string
	}
	RateDecay struct {
		Op               string
		StepSize         int
		StepGamma        float64
		PlateauFactor    float64
		PlateauPatience  int
		PlateauThreshold float64
		PlateauMin       float64
	}
}

Pytorch default training loop parameters.

type PytorchArch

type PytorchArch struct {
	ID     string
	Params PytorchArchParams
}

type PytorchArchComponent

type PytorchArchComponent struct {
	// PytorchComponent ID
	ID string
	// arbitrary JSON parameters
	Params string
	// where should component.Inputs come from
	// these must be layer or input dataset (not target dataset)
	Inputs []PytorchArchInput
	// where should component.Targets come from
	// these could be layer, input dataset, or target dataset
	Targets []PytorchArchInput
}

type PytorchArchInput

type PytorchArchInput struct {
	// dataset or layer
	Type string

	ComponentIdx int
	Layer        string

	DatasetIdx int
}

type PytorchArchLoss

type PytorchArchLoss struct {
	ComponentIdx int
	Layer        string
	Weight       float64
}

type PytorchArchParams

type PytorchArchParams struct {
	// datasets during training are numbered starting from inputs, then continuing with targets
	// DatasetIdx refer to this unified numbering scheme
	NumInputs  int
	NumTargets int

	Components []PytorchArchComponent
	Losses     []PytorchArchLoss
	Scores     []PytorchArchLoss
}

type PytorchComponent

type PytorchComponent struct {
	ID     string
	Params PytorchComponentParams
}

type PytorchComponentParams

type PytorchComponentParams struct {
	// the module can be defined one of three ways:
	// - a built-in module in exec_ops/pytorch/models/X.py
	// - a module X in a git repository Y
	// - hardcoded
	// only one of BuiltInModule, RepositoryModule, and Code should be set
	// if RepositoryModule is set, Repository must be as well
	Module struct {
		BuiltInModule string

		Repository       PytorchRepository
		RepositoryModule string

		Code string
	}

	// inputs/targets are provided as arguments to forward pass
	NumInputs  int
	NumTargets int

	// produces these recommended skyhook outputs
	Outputs map[string]DataType

	// forward pass output dict also includes these layers and losses
	Layers []string
	Losses []string

	Repositories []PytorchRepository
}

type PytorchInferParams

type PytorchInferParams struct {
	ArchID         string
	InputOptions   []PIInputOption
	OutputDatasets []PIOutputDataset
	// See PytorchTrainParams.Components
	Components map[int]string
}

type PytorchOpParams

type PytorchOpParams struct {
	Op     string
	Params string
}

type PytorchRepository

type PytorchRepository struct {
	URL string

	// Optional (empty string for latest commit in default branch)
	Commit string
}

A git repository that's used as a library in some component.

func (PytorchRepository) Hash

func (repo PytorchRepository) Hash() string

type PytorchTrainParams

type PytorchTrainParams struct {
	ArchID string
	// dataset options
	Dataset PytorchOpParams
	// data augmentation
	Augment []PytorchOpParams
	// restoring models, corresponding to the "models" input
	Restore []PRestore
	// training loop parameters
	Train PytorchOpParams
	// Configuring component parameters.
	// This is like PytorchArchComponent.Params, but just overrides or extends
	// those parameters with more options.
	// It is map from component index to JSON-encoded parameters.
	Components map[int]string
}

type RandomAccessDataSpec

type RandomAccessDataSpec interface {
	SequenceDataSpec
	// Initialize a SequenceReader that starts reading at index i, and reads up to index j.
	ReadSlice(format string, metadata DataMetadata, fname string, i, j int) SequenceReader
}

type ReadFfmpegOptions

type ReadFfmpegOptions struct {
	// The source of the encoded video data.
	// One of Fname or Reader must be set.
	Fname  string
	Reader io.Reader
	// If non-zero, the offset in the file to seek to before reading.
	Start int
	// If non-zero, read only this many frames.
	Length int
}

Read video file from fname with the given dimensions and framerate. Start and length specify a range of frame indexes to read, but can be 0 to read the entire file.

type RichText

type RichText struct {
	Text string
	X    int
	Y    int
}

type Runnable

type Runnable struct {
	Name           string
	Op             string
	Params         string
	InputDatasets  map[string][]Dataset
	OutputDatasets map[string]Dataset
}

func (Runnable) GetOp

func (node Runnable) GetOp() ExecOpProvider

type SequenceDataSpec

type SequenceDataSpec interface {
	DataSpec

	// Initialize a SequenceReader for reading data from storage.
	// The SequenceReader should read the data chunk by chunk.
	Reader(format string, metadata DataMetadata, r io.Reader) SequenceReader
	// Initialize a SequenceWriter to write chunk by chunk to storage.
	Writer(format string, metadata DataMetadata, w io.Writer) SequenceWriter

	// Slice operations on the sequence data.
	Length(data interface{}) int
	Append(data interface{}, more interface{}) interface{}
	Slice(data interface{}, i int, j int) interface{}
}

SequenceDataSpec describes sequence data types. These are any data types consisting of a sequence of elements. For example, Detections are sequences of []Detection, while videos are sequences of images.

type SequenceJsonDataImpl

type SequenceJsonDataImpl struct {
	Spec SequenceJsonSpec
}

func (SequenceJsonDataImpl) Append

func (s SequenceJsonDataImpl) Append(data interface{}, more interface{}) interface{}

func (SequenceJsonDataImpl) DecodeMetadata

func (s SequenceJsonDataImpl) DecodeMetadata(rawMetadata string) DataMetadata

func (SequenceJsonDataImpl) GetDefaultExtAndFormat

func (s SequenceJsonDataImpl) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (SequenceJsonDataImpl) GetMetadataFromFile

func (s SequenceJsonDataImpl) GetMetadataFromFile(fname string) (format string, metadata DataMetadata, err error)

func (SequenceJsonDataImpl) Length

func (s SequenceJsonDataImpl) Length(data interface{}) int

func (SequenceJsonDataImpl) Read

func (s SequenceJsonDataImpl) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (SequenceJsonDataImpl) ReadStream

func (s SequenceJsonDataImpl) ReadStream(r io.Reader) (data interface{}, err error)

func (SequenceJsonDataImpl) Reader

func (s SequenceJsonDataImpl) Reader(format string, metadata DataMetadata, r io.Reader) SequenceReader

func (SequenceJsonDataImpl) Slice

func (s SequenceJsonDataImpl) Slice(data interface{}, i int, j int) interface{}

func (SequenceJsonDataImpl) Write

func (s SequenceJsonDataImpl) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (SequenceJsonDataImpl) WriteStream

func (s SequenceJsonDataImpl) WriteStream(data interface{}, w io.Writer) error

func (SequenceJsonDataImpl) Writer

func (s SequenceJsonDataImpl) Writer(format string, metadata DataMetadata, w io.Writer) SequenceWriter

type SequenceJsonSpec

type SequenceJsonSpec interface {
	DecodeMetadata(rawMetadata string) DataMetadata
	DecodeData(bytes []byte) (interface{}, error)
	GetEmptyMetadata() (metadata DataMetadata)

	Length(data interface{}) int
	Append(data interface{}, more interface{}) interface{}
	Slice(data interface{}, i int, j int) interface{}
}

Implement DataSpec using simple JSON-only format.

type SequenceReader

type SequenceReader interface {
	Read(n int) (interface{}, error)
	Close()
}

func NewSliceReader

func NewSliceReader(spec SequenceDataSpec, format string, metadata DataMetadata, r io.Reader) SequenceReader

type SequenceWriter

type SequenceWriter interface {
	Write(data interface{}) error
	Close() error
}

type Shape

type Shape struct {
	Type   TypeOfShape
	Points [][2]int

	// Optional metadata
	Category string            `json:",omitempty"`
	TrackID  int               `json:",omitempty"`
	Metadata map[string]string `json:",omitempty"`
}

func (Shape) Bounds

func (shp Shape) Bounds() [4]int

type ShapeJsonSpec

type ShapeJsonSpec struct{}

func (ShapeJsonSpec) Append

func (s ShapeJsonSpec) Append(data interface{}, more interface{}) interface{}

func (ShapeJsonSpec) DecodeData

func (s ShapeJsonSpec) DecodeData(bytes []byte) (interface{}, error)

func (ShapeJsonSpec) DecodeMetadata

func (s ShapeJsonSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (ShapeJsonSpec) GetEmptyMetadata

func (s ShapeJsonSpec) GetEmptyMetadata() (metadata DataMetadata)

func (ShapeJsonSpec) Length

func (s ShapeJsonSpec) Length(data interface{}) int

func (ShapeJsonSpec) Slice

func (s ShapeJsonSpec) Slice(data interface{}, i int, j int) interface{}

type ShapeMetadata

type ShapeMetadata struct {
	CanvasDims [2]int   `json:",omitempty"`
	Categories []string `json:",omitempty"`
}

func (ShapeMetadata) Update

func (m ShapeMetadata) Update(other DataMetadata) DataMetadata

type SimpleExecOp

type SimpleExecOp struct {
	ApplyFunc func(ExecTask) error
	P         int
}

A wrapper for a simple exec op that needs no persistent state. So the wrapper just wraps a function, along with desired parallelism.

func (SimpleExecOp) Apply

func (e SimpleExecOp) Apply(task ExecTask) error

func (SimpleExecOp) Close

func (e SimpleExecOp) Close()

func (SimpleExecOp) Parallelism

func (e SimpleExecOp) Parallelism() int

type SliceReader

type SliceReader struct {
	Data interface{}
	Spec SequenceDataSpec
	// contains filtered or unexported fields
}

SequenceReader for sequence data that has already been read into memory.

func (*SliceReader) Close

func (r *SliceReader) Close()

func (*SliceReader) Read

func (r *SliceReader) Read(n int) (interface{}, error)

type SliceWriter

type SliceWriter struct {
	Spec     SequenceDataSpec
	Format   string
	Metadata DataMetadata
	Writer   io.Writer
	// contains filtered or unexported fields
}

SequenceWriter that stores everything in-memory until Close.

func (*SliceWriter) Close

func (w *SliceWriter) Close() error

func (*SliceWriter) Write

func (w *SliceWriter) Write(data interface{}) error

type StatusRequest

type StatusRequest struct {
	UUID string
}

coordinator->worker sent repeatedly to get status of the ContainerRequest

type StatusResponse

type StatusResponse struct {
	// whether the container has been provisioned
	Ready bool
	// if not Ready, some message e.g. position in queue
	Message string
	// if Ready, forwarded ExecBeginResponse
	ExecBeginResponse ExecBeginResponse
	// if Ready, base URL where container can be accessed
	BaseURL string
}

type StringJsonSpec

type StringJsonSpec struct{}

func (StringJsonSpec) Append

func (s StringJsonSpec) Append(data interface{}, more interface{}) interface{}

func (StringJsonSpec) DecodeData

func (s StringJsonSpec) DecodeData(bytes []byte) (interface{}, error)

func (StringJsonSpec) DecodeMetadata

func (s StringJsonSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (StringJsonSpec) GetEmptyMetadata

func (s StringJsonSpec) GetEmptyMetadata() (metadata DataMetadata)

func (StringJsonSpec) Length

func (s StringJsonSpec) Length(data interface{}) int

func (StringJsonSpec) Slice

func (s StringJsonSpec) Slice(data interface{}, i int, j int) interface{}

type TableData

type TableData [][]string

Rows of table.

type TableDataSpec

type TableDataSpec struct{}

func (TableDataSpec) DecodeMetadata

func (s TableDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (TableDataSpec) GetDefaultExtAndFormat

func (s TableDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (TableDataSpec) GetMetadataFromFile

func (s TableDataSpec) GetMetadataFromFile(fname string) (format string, metadata DataMetadata, err error)

func (TableDataSpec) Read

func (s TableDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (TableDataSpec) ReadStream

func (s TableDataSpec) ReadStream(r io.Reader) (interface{}, error)

func (TableDataSpec) Write

func (s TableDataSpec) Write(data interface{}, format string, metadata_ DataMetadata, w io.Writer) error

func (TableDataSpec) WriteSQLFile

func (d TableDataSpec) WriteSQLFile(data TableData, metadata TableMetadata, fname string) error

func (TableDataSpec) WriteStream

func (s TableDataSpec) WriteStream(data interface{}, w io.Writer) error

type TableMetadata

type TableMetadata struct {
	Columns []ColumnSpec `json:",omitempty"`
}

func (TableMetadata) Update

func (m TableMetadata) Update(other DataMetadata) DataMetadata

type TailJobOp

type TailJobOp struct {
	Lines []string
	// contains filtered or unexported fields
}

func (*TailJobOp) Encode

func (op *TailJobOp) Encode() string

func (*TailJobOp) Stop

func (op *TailJobOp) Stop() error

func (*TailJobOp) Update

func (op *TailJobOp) Update(lines []string)

type TypeOfShape

type TypeOfShape string

Shape types.

type VideoBuilder

type VideoBuilder struct {
	Metadata VideoMetadata
	Fname    string
	Writer   io.Writer
	// contains filtered or unexported fields
}

func (*VideoBuilder) Close

func (b *VideoBuilder) Close() error

func (*VideoBuilder) GetDuration

func (b *VideoBuilder) GetDuration() float64

Get the duration of the written video. Must only be called after Close().

func (*VideoBuilder) Write

func (b *VideoBuilder) Write(chunk interface{}) error

type VideoDataSpec

type VideoDataSpec struct{}

func (VideoDataSpec) Append

func (s VideoDataSpec) Append(data interface{}, more interface{}) interface{}

func (VideoDataSpec) DecodeMetadata

func (s VideoDataSpec) DecodeMetadata(rawMetadata string) DataMetadata

func (VideoDataSpec) FileReader

func (s VideoDataSpec) FileReader(format string, metadata DataMetadata, fname string) SequenceReader

func (VideoDataSpec) FileWriter

func (s VideoDataSpec) FileWriter(format string, metadata DataMetadata, fname string) SequenceWriter

func (VideoDataSpec) GetDefaultExtAndFormat

func (s VideoDataSpec) GetDefaultExtAndFormat(data interface{}, metadata DataMetadata) (ext string, format string)

func (VideoDataSpec) GetMetadataFromFile

func (s VideoDataSpec) GetMetadataFromFile(fname string) (format string, metadata DataMetadata, err error)

Use ffprobe to get the resolution and duration of the video. Framerate currently defaults to 10 fps.

func (VideoDataSpec) Length

func (s VideoDataSpec) Length(data interface{}) int

func (VideoDataSpec) Read

func (s VideoDataSpec) Read(format string, metadata DataMetadata, r io.Reader) (data interface{}, err error)

func (VideoDataSpec) ReadSlice

func (s VideoDataSpec) ReadSlice(format string, metadata DataMetadata, fname string, i, j int) SequenceReader

func (VideoDataSpec) ReadStream

func (s VideoDataSpec) ReadStream(r io.Reader) (data interface{}, err error)

func (VideoDataSpec) Reader

func (s VideoDataSpec) Reader(format string, metadata DataMetadata, r io.Reader) SequenceReader

func (VideoDataSpec) Slice

func (s VideoDataSpec) Slice(data interface{}, i int, j int) interface{}

func (VideoDataSpec) Write

func (s VideoDataSpec) Write(data interface{}, format string, metadata DataMetadata, w io.Writer) error

func (VideoDataSpec) WriteStream

func (s VideoDataSpec) WriteStream(data interface{}, w io.Writer) error

func (VideoDataSpec) Writer

func (s VideoDataSpec) Writer(format string, metadata DataMetadata, w io.Writer) SequenceWriter

type VideoIterator

type VideoIterator struct {
	Metadata VideoMetadata
	Fname    string
	Reader   io.Reader
	// contains filtered or unexported fields
}

VideoIterator duals as a SequenceReader for video.

func (*VideoIterator) Close

func (it *VideoIterator) Close()

func (*VideoIterator) Get

func (it *VideoIterator) Get(n int) ([]Image, error)

func (*VideoIterator) Iterate

func (it *VideoIterator) Iterate(n int, f func(Image)) error

func (*VideoIterator) Read

func (it *VideoIterator) Read(n int) (interface{}, error)

type VideoMetadata

type VideoMetadata struct {
	// view settings that can be adjusted
	Dims      [2]int `json:",omitempty"`
	Framerate [2]int `json:",omitempty"`

	// cached properties that don't make sense to adjust
	Duration float64 `json:",omitempty"`
}

func (VideoMetadata) NumFrames

func (m VideoMetadata) NumFrames() int

Approximate number of frames in this video.

func (VideoMetadata) Update

func (m VideoMetadata) Update(other DataMetadata) DataMetadata

type VideoReader

type VideoReader interface {
	// Error should be io.EOF if there are no more images.
	// If an image is returned, error must NOT be io.EOF.
	// (So no error should be returned on the last image, only after the last image.)
	Read() (Image, error)

	Close()
}

type VideoStreamHeader

type VideoStreamHeader struct {
	Width           int
	Height          int
	Channels        int
	Length          int
	BytesPerElement int
}

type VirtualNode

type VirtualNode struct {
	// from ExecNode
	Name   string
	Op     string
	Params string

	// Parents of this node.
	Parents map[string][]VirtualParent
	// the concrete node that this ExecNode was created from
	// if ExecOpImpl.Resolve is not set, then Node == OrigNode
	OrigNode ExecNode
	// A unique identifier for this node if it is actually virtual (Node != OrigNode).
	VirtualKey string
}

Like ExecNode, but knows its position in the dynamic execution graph. So it points to parent nodes/datasets with GraphIDs instead of database IDs. This is virtual because it may or may not be an actual configured node. (It may by created dynamically by ExecOpImpl.Resolve.)

func (VirtualNode) GetInputTypes

func (node VirtualNode) GetInputTypes() map[string][]DataType

func (VirtualNode) GetInputs

func (node VirtualNode) GetInputs() []ExecInput

func (VirtualNode) GetOp

func (node VirtualNode) GetOp() ExecOpProvider

func (VirtualNode) GetOutputs

func (node VirtualNode) GetOutputs() []ExecOutput

func (VirtualNode) GetRunnable

func (node VirtualNode) GetRunnable(inputDatasets map[string][]Dataset, outputDatasets map[string]Dataset) Runnable

func (VirtualNode) GraphID

func (node VirtualNode) GraphID() GraphID

func (VirtualNode) GraphParents

func (node VirtualNode) GraphParents() map[string]GraphID

func (VirtualNode) LocalHash

func (node VirtualNode) LocalHash() []byte

type VirtualParent

type VirtualParent struct {
	GraphID GraphID
	// if GraphID.Type is "exec", then this is name of output that we want to input
	Name string

	DataType DataType
}

Like ExecParent but points to an actual Node.

Jump to

Keyboard shortcuts

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