chathika / NL4Py

Bringing Your Turtles From NetLogo to Python 🐍🐢
GNU General Public License v3.0
51 stars 10 forks source link

NetLogo 6.1 compatibility #8

Closed LaCuneta closed 5 years ago

LaCuneta commented 5 years ago

Hello! Thank you for all your hard work on this project! I just wanted to alert you to a breaking change in NetLogo 6.1, as reported on StackOverflow

In NetLogo 6.1, the HeadlessWorkspace and App classes had a small change that is unfortunately breaking for Java apps. The open() and openModel() methods had an optional boolean parameter added for our new extension manager. That boolean parameter works great with Scala, but not with Java, which doesn't recognize the option/default value it can use. Example: https://github.com/NetLogo/NetLogo/blob/hexy/netlogo-gui/src/main/headless/HeadlessWorkspace.scala#L500

The update is fortunately easy, just provide the boolean value. It can be true to auto-install extensions on a per-user basis, or false in which case the user has to make sure extensions are available for their model on their own.

Feel free to let me know if you have any questions, and thanks again.

lfwells commented 5 years ago

Yep I would love to see this compatible with NetLogo 6.1, hopefully sounds like a simple fix?

If it helps, here is the crash info:

py4j.protocol.Py4JJavaError: An error occurred while calling t.openModel.
: java.lang.NoSuchMethodError: org/nlogo/headless/HeadlessWorkspace.open(Ljava/lang/String;)V (loaded from file:/C:/Program%20Files/NetLogo%206.1.0/app/netlogo-6.1.0.jar by sun.misc.Launcher$AppClassLoader@29c9a50d) called from class nl4py.server.HeadlessWorkspaceController (loaded from file:/C:/Users/USERNAME/AppData/Local/Programs/Python/Python36/Lib/site-packages/nl4py/nl4pyServer/NetLogoControllerServer.jar by sun.misc.Launcher$AppClassLoader@29c9a50d).        at nl4py.server.HeadlessWorkspaceController.openModel(HeadlessWorkspaceController.java:133)
        at nl4py.server.NetLogoControllerServer.openModel(NetLogoControllerServer.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
        at java.lang.reflect.Method.invoke(Method.java:508)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:214)
        at java.lang.Thread.run(Thread.java:785)
chathika commented 5 years ago

@LaCuneta Thank you for the work on NetLogo 6.1 and thanks to both you and @lfwells for bringing up the incompatibility! Sorry it's taken a while for me to catch up with the new version (grad student woes...).

You're right, the issue stems from the default value of the boolean parameter to HeadlessWorkspace.open(...) not being picked up by the NetLogoControllerServer.jar. It was an easy fix.

I've released version 0.5.2 which should let nl4py now support both NetLogo 6.0 and 6.1.

Thanks for pointing out the bug! Please let me know if you encounter any other compatibility issues with NetLogo 6.1.