cfmrp / mtool

Software to Manipulate Different Flavors of Semantic Graphs
http://mrp.nlpl.eu
GNU Lesser General Public License v3.0
51 stars 24 forks source link

Invalid top node id: --validate crashes instead of reporting the wrong id #60

Closed dan-zeman closed 5 years ago

dan-zeman commented 5 years ago

https://github.com/cfmrp/mtool/blob/0e4ada1e2f026864a07e080907062aff04a91c00/graph.py#L555

When "tops" in JSON refer to a node id that does not exist, main.py --validate does not recognize the error. Instead, it tries to set the is_top property of the non-existent node, which fails with a much less informative error message:

Traceback (most recent call last):
  File "/net/work/projects/mrptask/mtool/main.py", line 325, in 
    main();
  File "/net/work/projects/mrptask/mtool/main.py", line 191, in main
    id = arguments.id, n = arguments.n, i = arguments.i);
  File "/net/work/projects/mrptask/mtool/main.py", line 68, in read_graphs
    graph, overlay = next(generator);
  File "/lnet/spec/work/projects/mrptask/mtool/codec/mrp.py", line 8, in read
    graph = Graph.decode(json.loads(line.rstrip()))
  File "/lnet/spec/work/projects/mrptask/mtool/graph.py", line 555, in decode
    graph.find_node(i).is_top = True
AttributeError: 'NoneType' object has no attribute 'is_top'