Auto-completion with Python wrapper?

#1

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

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

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

0 Likes

#5

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

Bye
Yannick

0 Likes