Fix engine reuse with 'with input.x as y' statement - #474
Conversation
|
@ZabelinK Curious what your use of |
|
@anakrish
For example like this Initially I wanted to create a proper function which will get external_data as argument, but it seems that it isn't possible to pass arguments to incremental rules. Maybe it is possible to do this in some other way, but this was a moment when I discovered this issue. And for our case we realized that it would be better to prefetch this external data before policy evaluation and pass them as part of an input, so I didn't try to find other ways to combine incrementral rules with some data received during policy evaluation. |
This fix is suppose to solve the following issue
Consider the policy which has some 'with input.a as b' statement, if we try to reuse engine with this policy several times but with different input we will have an issue that during second evaluation with new input after interpreting 'with' statement we will overwrite input with input values from first evaluation. The reason is that
self.with_document['input']is used in interpretation of 'with' statement and it isn't updated in set_input and it isn't cleaned before second evaluation (because it was already prepared), in a result it keep input from first evaluation and each time policy does 'with as' it overwrite its full input.I am not sure that this is the best way to fix it, it seems to me that it is better to remove 'input' from self.with_document and use only self.input where needed, so we keep it only in one place and also 'input' doesn't seems to be conceptually part of a document. But I just wanted to highlight the issue and provide the minimal fix.