NoFlo: Subgraphs as components

425 views
Skip to first unread message

Henri Bergius

unread,
Dec 14, 2012, 4:43:15 AM12/14/12
to flow-based-...@googlegroups.com
Hi,

This is a bit of clarification on how subgraphs work in NoFlo 0.2
onwards, since there was a question about it:
https://github.com/bergie/noflo/issues/59#issuecomment-11370138

* Any NoFlo graph can EXPORT some of its input and output ports to
give more convenient names (so you can use IN instead of SOMENODE.IN,
etc)
* Any NPM module (the way you package and distribute libraries in
Node.js) can provide both graphs and components that NoFlo
applications can use
* From the "end-user perspective", there is no difference whether a
node runs a subgraph or a (programmed) component, but the API has a
"isSubgraph" method to check this for UI purposes

A good example is probably the NoFlo YAML module which provides some
programmed components:
https://github.com/bergie/noflo-yaml/tree/master/components

It also provides one reusable graph:
https://github.com/bergie/noflo-yaml/blob/master/graphs/ParseFrontmatter.fbp

All of these are declared in the package.json so that NoFlo's
ComponentLoader finds them:
https://github.com/bergie/noflo-yaml/blob/master/package.json#L23

You just need to install the noflo-yaml package inside your project
and these components/subgraphs become available:
https://npmjs.org/package/noflo-yaml

Here is an example of a NoFlo program that utilizes these graphs:
https://github.com/bergie/noflo-yaml/blob/master/examples/frontmatter.fbp

It simply does the following:
* Reads the contents of the given file
* Sends it to the yaml/ParseFrontmatter subgraph to be parsed
* ...and displays the results in STDOUT

Obviously real-world NoFlo programs are usually more sophisticated :-)

/Henri

--
Henri Bergius
Motorcycle Adventures and Free Software
http://bergie.iki.fi/

Jabber: henri....@gmail.com
Microblogs: @bergie

Kenneth Kan

unread,
Dec 17, 2012, 6:58:22 PM12/17/12
to flow-based-...@googlegroups.com
Oooooh! Now I get it! This is indeed brilliant! Superior to what came before it.

Does it mean the `'Graph.fbp' -> GRAPH Graph(Graph)` syntax will be deprecated?
Reply all
Reply to author
Forward
0 new messages