Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutating linker #19

Open
CJ-Wright opened this issue Dec 14, 2018 · 0 comments
Open

mutating linker #19

CJ-Wright opened this issue Dec 14, 2018 · 0 comments

Comments

@CJ-Wright
Copy link
Member

CJ-Wright commented Dec 14, 2018

xref: xpdAcq/xpdtools#62 (comment)

This produces an interesting pair of problems for the linker.

Since we have the qoi arg the pipeline the linker will look for a qoi upstream node to subscribe to. This node might not exist, or worse we may want to use this on multiple upstream nodes. I'm not certain how to handle this properly currently. One approach would be to modify the namespace dict before adding the tomography nodes. This would allow us to make a temporary qoi node which is the same as an existing node.
Sine we may use the tomo pipeline chunk multiple times we will need to modify the linker to make unique names for all the output names. This way we can keep them in the namespace without clashing.

def abs_chunk(img):
    abs = img.map(np.sum)
    return locals()

def tomo_chunk(qoi, ...):
    tomo = qoi.map(...)
    return locals()

def mutating_linker(func, namespace, input_lut, output_lut):
    # takes valid node name to qoi (abs -> qoi)
    for k, v in input_lut.items():
        namespace[k] = namespace[v]
    loc = func(**namespace)
    # takes output name and changes it (tomo -> abs_tomo)
    for k, v in output_lut.items():
        loc[v] = loc.pop(k)
    namespace.update(loc)
    # Note that this means that input_lut keys can't be a valid output node name
    # (qoi -> N/A)
    for k, v in input_lut.items():
        namespace.pop(k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant