# VTK review process documentation

**URL:** <https://discourse.vtk.org/t/vtk-review-process-documentation/6629>\
**Category:** Development\
**Created:** [September 14, 2021, 1:20pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629 "2021-09-14T13:20:27Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [September 22, 2021, 11:08pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/21 "2021-09-22T23:08:58Z")

</div>

@dgobbi The script seems to work quite well, I had to do a couple of little changes and bring in the option to manually add some imports in a similar way to what we do when developing C++ code. For example [ElevationBandsWithGlyphs](https://kitware.github.io/vtk-examples/site/Python/Visualization/ElevationBandsWithGlyphs/) needs

```auto
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2

```

whilst [CurvatureBandsWithGlyphs](https://kitware.github.io/vtk-examples/site/Python/Visualization/CurvatureBandsWithGlyphs/) does not. Excepting for the need to include numpy stuff, the imports are almost identical. The same modules are used - just differing by imported classes. This was tested with PyCharm and on the command line using vtkpython and also python directly. Other code, for example [CurvaturesAdjustEdges](https://kitware.github.io/vtk-examples/site/Python/PolyData/CurvaturesAdjustEdges/), also doesn’t need to import `vtkRenderingOpenGL2`.

Another interesting thing when using PyCharm is that

```auto
from vtkmodules.vtkInteractionWidgets import vtkCameraOrientationWidget

```

trigers a `Cannot find reference 'vtkCameraOrientationWidget' in ' __init__.py' ` in Windows but not in Linux.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 23, 2021, 1:01am UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/22 "2021-09-23T01:01:28Z")

</div>

Hi Andrew, what does “noinspection PyUnresolvedReferences” do?

My feeling is that it’s best to put “import vtkmodules.vtkRenderingOpenGL2” after importing the other rendering modules, instead of putting it at the top. The reason for this is that the other modules (vtkRenderingCore etcetera) are its dependencies, i.e. they come earlier in the topological sort.

CurvatureBandsWithGlyphs is still importing the “vtk” module and therefore it’s still pulling in everything. For vtkCameraOrientationWidget, it’s not in the release branch, only in the master.

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [September 23, 2021, 1:59am UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/23 "2021-09-23T01:59:18Z")

</div>

When you format the Python code in PyCharm unused imports are removed so “noinspection PyUnresolvedReferences” prevents their removal. PyCharm by default also sorts the imports alpabetically when `Reformat Code` run.

It can be disabled in PyCharm: **`Settings/Preferences | Editor | Code Style | Python | Imports`** so I will redo the imports. The script sorts the `from ... import ... statements` alphabetically and adds the additional commented out imports at the end thus it is no big deal. So I will do that and also move `from vtk.util import numpy_support` to the end on the imports.

> [@dgobbi](#):
>
> CurvatureBandsWithGlyphs is still importing the “vtk” module and therefore it’s still pulling in everything.

I see this is the line `from vtk.util import numpy_support` this explains a lot! I understand now, thanks.

> [@dgobbi](#):
>
> For vtkCameraOrientationWidget, it’s not in the release branch, only in the master.

I am actually using the master in both Windows and Linux.

Thanks for your comments it has really clarified a lot for me.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [September 23, 2021, 12:35pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/24 "2021-09-23T12:35:30Z")

</div>

> [@dgobbi](#):
>
> My feeling is that it’s best to put “import vtkmodules.vtkRenderingOpenGL2” after importing the other rendering modules, instead of putting it at the top. The reason for this is that the other modules (vtkRenderingCore etcetera) are its dependencies, i.e. they come earlier in the topological sort.

The module `.py` files import (direct VTK module) dependencies automatically, so there’s no real need for users to know the toposort of the modules they’d like to import.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 23, 2021, 1:01pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/25 "2021-09-23T13:01:07Z")

</div>

> [@ben.boeckel](#):
>
> The module `.py` files import (direct VTK module) dependencies automatically, so there’s no real need for users to know the toposort of the modules they’d like to import.

I do realize this, but if the list of modules is being created by a script (as is the case here), topological ordering makes the most sense. The reason: if an exception occurs during import, this gives the shortest and most informative stack trace. This is particularly true when importing .so/.pyd modules as opposed to .py modules.

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [September 23, 2021, 1:30pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/26 "2021-09-23T13:30:58Z")

</div>

From my viewpoint I don’t like the idea of disabling the default import sorting in PyCharm because it adds another layer of complexity for new users and for users switching between different machines and operating systems. It’s years since I have used Eclipse but I suspect imports are also sorted by default. So I would like to keep default settings on IDE’s as much as possible.One less thing to check when people submit a MR.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [September 23, 2021, 1:54pm UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/27 "2021-09-23T13:54:35Z")

</div>

> [@dgobbi](#):
>
> The reason: if an exception occurs during import, this gives the shortest and most informative stack trace.

I agree, but you’re fighting tooling at that point and anything that isn’t topo == alpha order means inserting extra newlines to keep formatters happy. The fix is to just be robust to any import order just like we should be with C++ headers because we _could_ keep those topo-sorted too, but discovering and remembering that order is _way_ more difficult (and even Python is hard). The best we end up doing is separating into groups like “own header”, “VTK”, “stdlib”, “extdeps”, etc.

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [September 25, 2021, 6:51am UTC](https://discourse.vtk.org/t/vtk-review-process-documentation/6629/28 "2021-09-25T06:51:28Z")

</div>

@ben FYI, I rewrote and modernised `VTK/Maintenance/WhatModulesVTK.py` and renamed it [VTKModulesForCxx](https://kitware.github.io/vtk-examples/site/Python/Utilities/VTKModulesForCxx/) so it is now in the VTK Examples alongside [VTKImportsForPython](https://kitware.github.io/vtk-examples/site/Python/Utilities/VTKImportsForPython/).

[Previous page](https://discourse.vtk.org/t/vtk-review-process-documentation/6629.md?page=1)
