Closed stigrj closed 4 years ago
In a discussion with Stig and Roberto we are aiming at this:
One solution we discussed is to reshuffle the tree (as extracted from template.yml
) into a directed acyclic graph (DAG) using NetworkX. If there are circular dependencies, then there is no DAG and hence we error out.
Reminder to actually test for circular dependencies.
To check my understanding of the problem: We want to detect cyclic dependencies and abort at the generate step, right? So this is an error that only the code developer using parselglossy can see, but never the user of the code that uses the generated parser. Correct?
Correct. These are issues that happen in the template.yml
specification and can be detected separately from any parsing, in https://github.com/dev-cafe/parselglossy/blob/dd57c64a278b0ba837743ab00fe24321cfda3342/parselglossy/validation.py#L89
I think that cycles can happen when:
view_by_default
.view_by_predicates
.Thanks! I experimented a bit with networkx
and agree that this is the way to go and should not be too difficult.
Working on it ...
:hammer_and_wrench:
But right now the generator does not call any of these validators AFAICS - is this by design or by history?
It checks whether the template is valid with is_template_valid
: https://github.com/dev-cafe/parselglossy/blob/master/parselglossy/api.py#L172-L179
Thanks! I was working in the wrong function (validate_from_dicts).
It's only now that I understand that these are really two issues. One is to sort the graph, and the other is to detect whether the graph is sortable.
Description
The following chain of dependencies currently does not work if neither
bar
norbaz
is set:It seems
baz
is first set equal to the string"user['foo']"
(which is a type mismatch), beforebar
is set to the value offoo
. Related to issue #73.