~sbinet/talks

3364a70e7e0c2338aff08308d005d1864afc3299 — Sebastien Binet 5 months ago aa34447 main
2019-10-22-golab-io-gohep: add missing assets
A 2019/2019-10-22-golab-io-gohep/_code/fwk-ifaces.go => 2019/2019-10-22-golab-io-gohep/_code/fwk-ifaces.go +56 -0
@@ 0,0 1,56 @@
import "reflect"

// START-comp OMIT
// Component is the interface satisfied by all values in fwk.
//
// A component can be asked for:
// its Type() (ex: "go-hep.org/x/hep/fads.MomentumSmearing")
// its Name() (ex: "MuonsMomSmearing")
type Component interface {
	Type() string
	Name() string
}

// END-comp OMIT
// START-task OMIT
// Task is a component processing event-level data.
// Task.Process is called for every component and for every input event.
type Task interface {
	Component

	StartTask(ctx Context) error
	Process(ctx Context) error
	StopTask(ctx Context) error
}

// END-task OMIT
// START-ctx OMIT
// Context is the interface to access context-local data.
type Context interface {
	ID() int64      // id of this context (e.g. entry number or some kind of event number)
	Slot() int      // slot number in the pool of event sequences
	Store() Store   // data store corresponding to the id+slot
	Msg() MsgStream // messaging for this context (id+slot)

	// Svc retrieves an already existing Svc by name.
	Svc(n string) (Svc, error)
}

// END-ctx OMIT
// START-ports OMIT
// DeclPorter is the interface to declare input/output ports for the data flow.
type DeclPorter interface {
	DeclInPort(name string, t reflect.Type) error
	DeclOutPort(name string, t reflect.Type) error
}

// END-ports OMIT
// START-store OMIT
// Store provides access to a concurrent-safe map[string]interface{} store.
type Store interface {
	Get(key string) (interface{}, error)
	Put(key string, value interface{}) error
	Has(key string) bool
}

// END-store OMIT

A 2019/2019-10-22-golab-io-gohep/_code/fwk-job.go => 2019/2019-10-22-golab-io-gohep/_code/fwk-job.go +42 -0
@@ 0,0 1,42 @@
package main

// START-job OMIT
// job is the scripting interface to 'fwk'
import "go-hep.org/x/hep/fwk/job"

func main() {
	// create a default fwk application, with some properties
	app := job.New(job.P{
		"EvtMax": 10,
		"NProcs": 2,
	})

	// ... cont'd on next page...
	// END-job OMIT

	// START-run OMIT
	// create a task that reads integers from some location
	// and publish the square of these integers under some other location
	app.Create(job.C{
		Type: "go-hep.org/x/hep/fwk/testdata.task2",
		Name: "t2",
		Props: job.P{
			"Input":  "t1-ints1",
			"Output": "t1-ints1-massaged",
		},
	})
	// create a task that publish integers to some location(s)
	app.Create(job.C{
		Type: "go-hep.org/x/hep/fwk/testdata.task1",
		Name: "t1",
		Props: job.P{
			"Ints1": "t1-ints1",
			"Ints2": "t2-ints2",
			"Int1":  int64(10), // initial value for the Ints1
			"Int2":  int64(20), // initial value for the Ints2
		},
	})
	app.Run()
}

// END-run OMIT

A 2019/2019-10-22-golab-io-gohep/_code/fwk1-example.sh => 2019/2019-10-22-golab-io-gohep/_code/fwk1-example.sh +21 -0
@@ 0,0 1,21 @@
$ fwk-ex-tuto-1
::: fwk-ex-tuto-1...
t2                   INFO configure...
t2                   INFO configure... [done]
t1                   INFO configure ...
t1                   INFO configure ... [done]
t2                   INFO start...
t1                   INFO start...
app                  INFO >>> running evt=0...
t1                   INFO proc... (id=0|0) => [10, 20]
t2                   INFO proc... (id=0|0) => [10 -> 100]
[...]
app                  INFO >>> running evt=9...
t1                   INFO proc... (id=9|0) => [10, 20]
t2                   INFO proc... (id=9|0) => [10 -> 100]
t2                   INFO stop...
t1                   INFO stop...
app                  INFO cpu: 654.064us
app                  INFO mem: alloc:             62 kB
app                  INFO mem: tot-alloc:         74 kB
::: fwk-ex-tuto-1... [done] (cpu=788.578us)

A 2019/2019-10-22-golab-io-gohep/_figs/avatar.png => 2019/2019-10-22-golab-io-gohep/_figs/avatar.png +0 -0
A 2019/2019-10-22-golab-io-gohep/_figs/funfast-nogo_svg.png => 2019/2019-10-22-golab-io-gohep/_figs/funfast-nogo_svg.png +0 -0
A 2019/2019-10-22-golab-io-gohep/_figs/funfast_svg.png => 2019/2019-10-22-golab-io-gohep/_figs/funfast_svg.png +0 -0