ipython/ipynb

Implement better dependency tracking for ipynb.fs.defs

yuvipanda opened this issue · 4 comments

Right now, we only include assignments where the LHS is all caps. However, LHS all caps might have dependencies on RHS that's not all caps. These will not be evaluated, causing strange amounts of confusion.

Instead, we should attempt to track the dependencies on the RHS of such assignments, and eval those too (recursively). We should do this in such a way that the rules are very clear to explain to people.

This should still only be done for top level imports though.

Hmm, can we get away with supporting only top-level things? What do we do with:

if a == 5:
    b = 6

C = b * 5

In this case I'll have to include all the the code, including the if (and the dependent a definition, wherever that comes from).

And what do you do with:

if a == 5:
    b = 6
else:
    b = 9
    doSomethingReallyExpensiveWithLotsOfSideEffects()

C = b * 5

Do we strip out doSomethingReallyExpensiveWithLotsOfSideEffects() but leave b = 9? That seems like very unintuitive behavior.

@ellisonbg suggested we use notebook tags, and I like that much better than magical solutions that involve AST munging or bytecode disassembly.

FWIW, we went down the same introspection path in https://github.com/jupyter-incubator/contentmanagement and instead backed off to using comment syntax as a stopgap tagging UI.