-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Currently we have half of a graph solver via the linker function. The linker function takes in a namespace hands it to the pipeline chunk function and then appends the output to the current namespace, and repeats. This allows us to solve the graph, attaching all the nodes together in the correct order, if we have the correct order for the links to be done. If the order is incorrect then we run into problems, as we will try to use parts of the namespace which don't exist yet. This is sub-optimal as it requires that we know the order at any point in time, which might not be true (eg. if we start composing pipelines dynamically we might not know the order ahead of time). The proper solution to this requires having for each pipeline chunk the required inputs and the outputs. The inputs are easy, they are the args to the function so we can go and look them up. The outputs are less so. Since we use the locals() function to avoid writing the explicit outputs we don't have any actual access to them until the function is run.
A potential solution to this problem is to spoof the namespace. By passing in dummy Stream objects we can see exactly what the output of the chunk is allowing us to get the output part of the chunk. With both the chunk inputs (via inspect.getargspec) and the outputs we can then get the correct order in which the nodes need to be created via chunks.
eg
def inspect_chunk(chunk)
args = inspect.getargspec(chunk)[0]
ns = chunk(**{k: Stream() for k in args})
streams = [k for k in ns if isinstance(ns[k], Stream) and k not in args]
return args, streamsNote that one could potentially call these chunks metanodes.
Note that this means each input/output node needs to have a unique name, which might not be a bad thing. (This will produce problems for the tomo system, but we were going to have problems on that front anyway, since it really is a metanode factory-like thing.