Auto-completion with Python wrapper?

Hi all,

I have recently started using the Orekit Python wrapper. I really like having access to the whole Python ecosystem while keeping the power of Orekit. So thank you very much Petrus for all the hard work behind this !

However, one thing is bothering me : I cannot get the auto-completion of my IDE to recognize the wrapper classes. It works fine for other libraries, but not with orekit. I’m guessing it has something to do with the technology used to build the wrapper, maybe ?

Is there a trick that I am missing to get this completion to work ? Or is it just impossible due to the nature of the wrapper ? I’m using PyCharm (community edition), but I’d be ready to switch to another IDE if it can get me auto-completion.

Thanks in advance for any help.
Yannick

Hi Yannick,

I don’t have auto-completion working in PyCharm with Orekit either.

But it works in JupyterLab. After running import orekit, auto-completion is available for modules. After starting the JVM, it works for objects as well. Nevertheless, the docstrings for function parameters are not very useful: Docstring: <no docstring> Type: builtin_function_or_method

If it can be improved, I would be eager to help @petrus.hyvonen

Cheers
yzokras

Hi Yannick and Yzokras,

Yes you are right, pycharm is doing some static analysis of the classes and as orekit wrapper is not python files it does not find it. Dynamic completion works, as in jupyter notebooks, but also in the pycharm python shell. The interactive debug in pycharm is really useful, and it has completion. I do not know if there is any possibilities or API for class discovery for compiled classes. Would be nice.

And regarding docstrings, yes they are not populated today. I was digging a bit in this some time ago, and it should probably be not too hard to make them a bit more descriptive like which parameters a method has. The really nice thing to have would be the proper docstrings, but this would require much more parsing and messing about as the docstring is not saved in the jar file and needs to be extracted somehow.

Both these things are generated by the JCC tool, so that’s where one need to start to improve things, help is welcome. It has a bit steep curve to enter as it is code generation in c++ to wrap java JNI calls, and then the c interface to Python.

Regards
/Petrus

Hi all,

I’m using PyDev plugin for Eclipse and auto-completion works well.
The interactive debug is ok too. I don’t know PyCharm so I could not tell which debugger is the best.

Cheers,
Maxime

Thank you all for the tips ! I will consider switching to Eclipse/PyDev.

Bye
Yannick

Hello everyone!

After quite a bit of research on all mentioned IDEs above, I found an additional solution to autocomplete, which works well for me.

I use IntelliJ with the Python Plugin, and then add the jar files of Orekit and Hipparchus as library modules. (the jar files that are contained in the orekit python package (inside conda site-packages folder))

This way, I have autocomplete in the editor of IntelliJ, as well as in its debugger (make sure to turn “Variable Loading Policy” to On-Demand or Synchronous, accrding to this issue fix, otherwise debugger crashes)

On another note, I managed to make Eclipse and Pydev work, but I want to add that I need to start
Eclipse through a batch file that activates the conda environment first. Autocomplete is then present on the editor of PyDev as well.

I prefer IntelliJ & Python plugin to PyDev, because of the ability to view DataFrames from the variable explorer, and because of InteliJ’s debugger with autocomplete.

Are there any updates to your preffered Python IDE workflow?

I hope this is useful to someone!
Manny

Hi Manny,
Thanks for sharing, didn’t know it was possible to use the java completions in that way - will try it out!

Otherwise not much news on the IDE workflow that I am using, PyCharm (will look at IntelliJ instead) for larger projects and Jupyter notebooks for analysis stuff. In jupyter you also get the tab-completion, as it is analyzing the objects on the fly.

Regards
/Petrus

1 Like

I recommend to try Codelobster IDE for python development - CodeLobster - Python Free Portable IDE with support Drupal, Smarty, Twig, WordPress, Joomla, JQuery, CodeIgniter, HTML, CSS, JavaScript, AngularJS, , MeteorJS, BackboneJS, CakePHP, Facebook, Laravel, Symfony, Yii, Node.js

Hi,

Just an update of this, since a few month the orekit conda-forge package contains also a set of Python stub files that helps IDE’s (at least VS Code and PyCharm) with docstrings and auto-completion.