BreakingBytes / simkit

Model Simulation Framework
http://breakingbytes.github.io/simkit/
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Automatic calculation dependency detection #116

Open mikofski opened 6 years ago

mikofski commented 6 years ago

Currently calculation dependencies have to be entered manually, which is a bit redundant and often leads to errors.

Carousel should automatically detect dependencies by comparing the output arguments to returns from other calculations.

For example:

class MyCalc(Calculation):
    calc1 = CalcParameter(
        formula='f_my_formula',
        args={'data': {'x': 'arg1'}, 'outputs': {'y': 'arg2'}},
        returns=['arg3']
    )
    calc2 = CalcParameter(
        formula='f_my_other_formula',
        args={'data': {'w': 'arg0'}, 'outputs': {'z': 'arg3'}},
        returns=['arg4']
    )

So it's obvious that calc2 depends on calc1 because it uses arg3 for z in f_my_other_formula which is a return from calc1.