[🐛 Bug Report]: Visualization draw_model function crashes on None/Null
See original GitHub issueDescribe the bug
From the This example notebook Visualization.ipynb:
Call to neuralogic.utils.visualize.draw_model function, draw_model(model), results in the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-59797e1249fd> in <module>
7 model = template.build(Backend.JAVA, Settings())
8
----> 9 draw_model(model)
...\lib\site-packages\neuralogic\utils\visualize\__init__.py in draw_model(model, filename, draw_ipython, img_type, value_detail, *args, **kwargs)
93 template_drawer = get_template_drawer(get_drawing_settings(img_type=img_type, value_detail=value_detail))
94
---> 95 return draw(template_drawer, template, filename, draw_ipython, img_type, *args, **kwargs)
96
97
...\lib\site-packages\neuralogic\utils\visualize\__init__.py in draw(drawer, obj, filename, draw_ipython, img_type, *args, **kwargs)
55 return
56
---> 57 data = bytes(drawer.drawIntoBytes(obj))
58
59 if draw_ipython:
TypeError: cannot convert 'NoneType' object to bytes
Similarly, adding a filename to the call (draw_model(model, 'img.png'), see code snippets below) results in a NullPointerException:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
...\lib\site-packages\_jpype.cp38-win_amd64.pyd in cz.cvut.fel.ida.drawing.Drawer.drawIntoFile()
...\lib\site-packages\_jpype.cp38-win_amd64.pyd in cz.cvut.fel.ida.drawing.GraphViz.writeImageToFile()
~\Anaconda3\envs\bakalarka\lib\site-packages\_jpype.cp38-win_amd64.pyd in java.io.FileOutputStream.write()
Exception: Java Exception
The above exception was the direct cause of the following exception:
java.lang.NullPointerException Traceback (most recent call last)
<ipython-input-8-91eec29cdcf5> in <module>
7 model = template.build(Backend.JAVA, Settings())
8
----> 9 draw_model(model, 'img.png')
...\lib\site-packages\neuralogic\utils\visualize\__init__.py in draw_model(model, filename, draw_ipython, img_type, value_detail, *args, **kwargs)
93 template_drawer = get_template_drawer(get_drawing_settings(img_type=img_type, value_detail=value_detail))
94
---> 95 return draw(template_drawer, template, filename, draw_ipython, img_type, *args, **kwargs)
96
97
...\lib\site-packages\neuralogic\utils\visualize\__init__.py in draw(drawer, obj, filename, draw_ipython, img_type, *args, **kwargs)
51 def draw(drawer, obj, filename: Optional[str] = None, draw_ipython=True, img_type="png", *args, **kwargs):
52 if filename is not None:
---> 53 drawer.drawIntoFile(obj, os.path.abspath(filename))
54
55 return
java.lang.NullPointerException: java.lang.NullPointerException
Steps to reproduce the behavior
I have come across this error in my own example codes, but it is enough to run the Visualization.ipynb notebook, concretely:
from neuralogic.utils.visualize import draw_model
from neuralogic.utils.data import XOR_Vectorized
from neuralogic.core import Settings, Backend
template, dataset = XOR_Vectorized()
model = template.build(Backend.JAVA, Settings())
draw_model(model)
For the NullPointerException, I used:
from neuralogic.utils.visualize import draw_model
from neuralogic.utils.data import XOR_Vectorized
from neuralogic.core import Settings, Backend
template, dataset = XOR_Vectorized()
model = template.build(Backend.JAVA, Settings())
draw_model(model, 'img.png')
Expected behavior
I should be able to visualize the model.
Environment
No response
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
[functions] NPE crashes in production · Issue #6007 - GitHub
Bug report I'm receiving crash reports in production with the following stack-trace: Fatal Exception: java.lang.
Read more >Capture and read bug reports - Android Developers
A bug report contains device logs, stack traces, and other diagnostic information to help you find and fix bugs in your app.
Read more >Strange iOS Crash Only on iOS 13.X… - Apple Developer
It is happening on some of the devices that run iOS 13.0 ~ 13.3. So I suppose it is happening while lunching the...
Read more >Solved: Archicad continous crashing (Bug report)
Solved: Hello, I spent all of today trying to find a way to allow me to do any of the following without crashing:...
Read more >Potential Bug Fixes in R2023a Prerelease - MATLAB & Simulink
Product Record Bug Summary
Deep Learning Toolbox 2803451 Image generation experiment template errors
MATLAB 2736745 Security Issue: who ‑file might execute code
MATLAB 2739217 tab completion...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I bumped the version to 0.1.5 and the drawing works fine on macOS. Thanks. Unfortunately I don’t have rights to close the issue.
I can confirm it works for me on Windows, both in the visualization notebook and in my own experiment. Thanks! @borisrakovan, feel free to close this issue, if you can confirm the issue is solved on macOS, as well.