Support IntelliSense with ontology information
It would be a nice feature to get autocompletion and argument information when instantiating objects from the ontology classes. For example, the code:
from osp.core.namespaces import cuba
wrapper = cuba.Wrap
Should suggest the autocompletion to Wrapper, and inform that it requires a session parameter.
I am not sure how easy, or even if it is possible, but I think it is definitely worth looking into at some point.
Things that should be implemented:
- [ ] Autocompletion of namespace elements (IPython).
- [ ] Autocompletion of namespace elements (IDE).
- [ ] Get info about ontology classes, relationships and attributes based on the ontology annotation properties using the IPython ? and ?? operators.
- [ ] Tooltip with info about ontology classes, relationships and attributes based on the ontology annotation properties on IDEs.
- [ ] Make pico update the stubs on installation/uninstallation/reinstallation of ontologies.
Possibly related, detection of the existing namespaces would also be useful.
See:

I started to work on this in the linked pull request, but later I realized that it is only possible to solve this issue in a simple way when the user is working with IPython.
When using IPython (i.e. Jupyter notebooks), some times the user will be coding when the namespace has been already imported. Therefore, the __dir__ method of the osp.core.namespaces package will have been defined, and autocompletion is possible. Of course, if the user has not yet imported the namespace, then the autocompletion of the ontology entities will not be possible. Nevertheless, implementing this would still be a positive change, so I did it.
However, when using an IDE such as VSCode or Pycharm, the story is different. The IDE does not run the code and keep a Python kernel with the result, so it cannot use the __dir__ method for autocompletion. So in principle, unless officially supported by the IDE or as a plug-in, this would be imposibble.
There is however a hacky "solution", which I do not like too much, but maybe @yoavnash, which is a user of OSP-core and I think needs this feature can give better input on this. There exist Python type hinting stub files (pyi extension), which allow a developer to supply type hinting while keeping the code in the py file itself clean, so that for example, it can be kept compatible with Python 2.
The trick is, that in this file you can specify types for things that do not actually exist in the py file itself. Look at the picture below.

It is up to the IDE to support those pyi files. I know that at least PyCharm supports them. I do not know about the VSCode Python plugins. When the file pictured above is included, indeed PyCharm is offering me to autocomplete both the namespace name and the Integer entity inside it.
Since these stub files do not need to be included in the same package as the python files themselves, I though that OSP-core could generate a osp-core-ontology-stubs package each time an ontology is installed or uninstalled, and put it in ~/.osp_ontologies. Then either the user could reinstall the package or OSP-core itself could launch the reinstallation.
Do you think this would bring the intended benefit and is worth implementing? Did any better idea come to your mind? Should we just accept that this is too hacky and close the issue?
I think it might relate to this?