IRC-SPHERE / HyperStream

HyperStream
https://irc-sphere.github.io/HyperStream/
MIT License
13 stars 5 forks source link

Node creation syntax #11

Closed tdiethe closed 7 years ago

tdiethe commented 7 years ago

At the moment is that all of the nodes have to be created up front (w.create_node(stream_name, channel_id, plate_ids)) and, and since we also store a dict of stream_name->node at the same time (N), they can then be accessed during workflow creation using N['whatever']. I'd actually like to get rid of this, so that you can use notation like the following:

X = hs.plate_manager.plates["X"]

with hs.create_workflow(**kwargs) as w:
    for x in X:
        my_node[x] = hs.factors.my_tool(w, sources=[])

Of course this can't work because my_node hasn't yet been defined. To define it, we need to know what channel it belongs in, and take a reference to the workflow. One way to do this would be to put references to the channels in the workflow, so the last line would become:

        w.channels.memory.my_node[x] = hs.factors.my_tool(w, sources=[])

although I'm not sure if that's going to work either (well it can, but it will be ugly). Actually, there are two references to the workflow on that line (one for the node, and one for the factor), so perhaps old way of referencing the channel could be used:

     M['my_node'][x] = hs.factors.my_tool(w, sources=[])

or another alternative would be to move the channel specification to the right, e.g.:

    w.nodes[x] = hs.factors.my_tool(w, sources=[], channel='memory')
tdiethe commented 7 years ago

Closing this for now. The current syntax looks like:

M = hs.channel_manager.memory
with hs.create_workflow(workflow_id=workflow_id, **workflow_parameters) as w:
    ticker = w.create_node(stream_name="ticker", channel=, plate_ids=["T"])
    for plate_value in hs.plate_manager.plates["T"]:
        ticker_repeated[plate_value] = hs.factors.clock(sources=[])
    time_interval = TimeInterval(t1, t1 + minute)
    w.execute(time_interval)