https://github.com/orktes/influunt
Dataflow programming for Golang and Python
https://github.com/orktes/influunt
dataflow-programming golang machine-learning python
Last synced: 9 months ago
JSON representation
Dataflow programming for Golang and Python
- Host: GitHub
- URL: https://github.com/orktes/influunt
- Owner: orktes
- License: mit
- Created: 2018-07-17T06:31:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-12T11:59:42.000Z (over 7 years ago)
- Last Synced: 2024-04-15T12:10:58.495Z (almost 2 years ago)
- Topics: dataflow-programming, golang, machine-learning, python
- Language: Go
- Size: 89.8 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
WORK IN PROGRESS
[](https://travis-ci.org/orktes/influunt)
[](https://godoc.org/github.com/orktes/influunt/go)
# influunt
Dataflow programming for Golang and Python
## Example (create in Python & run in Go)
First create the graph in python and save it to a file
```python
import influunt
with influunt.Graph() as graph:
# input placeholder
inputItems = influunt.placeholder()
# Map items and returns value + 1
values = inputItems.map(lambda item, i : item.value + 1)
# Map items and return names
names = inputItems.map(lambda item, i : item.name)
# Save graph as a model and define inputs and outputs
influunt.save_model(
graph,
{"input": inputItems},
{"values": values, "names": names},
"example.model"
)
```
Load graph in go and execute
```go
import (
"fmt"
"os"
"github.com/orktes/influunt/go"
"github.com/orktes/influunt/go/executor"
)
func main() {
file, _ := os.Open("example.model")
model, _ := influunt.ReadModel(file)
exec, _ := executor.NewModelExecutor(model)
results, _ := exec.Run(map[string]interface{}{
"input": []map[string]interface{}{
{"name": "foo", "value": 100},
{"name": "bar", "value": 200},
},
})
fmt.Printf("%+v\n", results["names"])
// [foo bar]
fmt.Printf("%+v\n", results["values"])
// [101 201]
}
```